<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $seconds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct()
  {
    $this->seconds = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond_index($index)
  {
    $aSecond = $this->seconds[$index];
    return $aSecond;
  }

  public function getSeconds()
  {
    $newSeconds = $this->seconds;
    return $newSeconds;
  }

  public function numberOfSeconds()
  {
    $number = count($this->seconds);
    return $number;
  }

  public function hasSeconds()
  {
    $has = $this->numberOfSeconds() > 0;
    return $has;
  }

  public function indexOfSecond($aSecond)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->seconds as $second)
    {
      if ($second->equals($aSecond))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public static function minimumNumberOfSeconds()
  {
    return 0;
  }

  public function addSecond($aSecond)
  {
    $wasAdded = false;
    if ($this->indexOfSecond($aSecond) !== -1) { return false; }
    $this->seconds[] = $aSecond;
    if ($aSecond->indexOfFirst($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aSecond->addFirst($this);
      if (!$wasAdded)
      {
        array_pop($this->seconds);
      }
    }
    return $wasAdded;
  }

  public function removeSecond($aSecond)
  {
    $wasRemoved = false;
    if ($this->indexOfSecond($aSecond) == -1)
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfSecond($aSecond);
    unset($this->seconds[$oldIndex]);
    if ($aSecond->indexOfFirst($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aSecond->removeFirst($this);
      if (!$wasRemoved)
      {
        $this->seconds[$oldIndex] = $aSecond;
        ksort($this->seconds);
      }
    }
    $this->seconds = array_values($this->seconds);
    return $wasRemoved;
  }

  public function addSecondAt($aSecond, $index)
  {  
    $wasAdded = false;
    if($this->addSecond($aSecond))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveSecondAt($aSecond, $index)
  {
    $wasAdded = false;
    if($this->indexOfSecond($aSecond) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addSecondAt($aSecond, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($copyOfSeconds as $aSecond)
    {
      $aSecond->removeFirst($this);
    }
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

  public function setSeconds(Second... $newSeconds)
  {
          return "";
  }

  public function isNumberOfSecondsValid()
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $second;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct($aSecond)
  {
    $didAddSecond = $this->setSecond($aSecond);
    if (!$didAddSecond)
    {
      throw new Exception("Unable to create first due to second. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond()
  {
    return $this->second;
  }

  public function setSecond($aSecond)
  {
    $wasSet = false;
    if ($aSecond == null)
    {
      return $wasSet;
    }
    
    $existingSecond = $this->second;
    $this->second = $aSecond;
    if ($existingSecond != null && $existingSecond != $aSecond)
    {
      $existingSecond->removeFirst($this);
    }
    $this->second->addFirst($this);
    $wasSet = true;
    return $wasSet;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $placeholderSecond = $this->second;
    $this->second = null;
    $placeholderSecond->removeFirst($this);
  }

  public function addSecond(Second $aSecond)
  {
          return "";
  }

  public function getSeconds()
  {
          return "";
  }

  public function setSeconds(Second... $newSeconds)
  {
          return "";
  }

  public function numberOfSeconds()
  {
          return "";
  }

  public function hasSeconds()
  {
          return "";
  }

  public function indexOfSecond(Second $second)
  {
          return "";
  }

  public function isNumberOfSecondsValid()
  {
          return "";
  }

  public function removeSecond(Second $second)
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $seconds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct($allSeconds)
  {
    $this->seconds = array();
    $didAddSeconds = $this->setSeconds($allSeconds);
    if (!$didAddSeconds)
    {
      throw new Exception("Unable to create First, must have 1 to 5 seconds. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond_index($index)
  {
    $aSecond = $this->seconds[$index];
    return $aSecond;
  }

  public function getSeconds()
  {
    $newSeconds = $this->seconds;
    return $newSeconds;
  }

  public function numberOfSeconds()
  {
    $number = count($this->seconds);
    return $number;
  }

  public function hasSeconds()
  {
    $has = $this->numberOfSeconds() > 0;
    return $has;
  }

  public function indexOfSecond($aSecond)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->seconds as $second)
    {
      if ($second->equals($aSecond))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public function isNumberOfSecondsValid()
  {
    $isValid = $this->numberOfSeconds() >= self::minimumNumberOfSeconds() && $this->numberOfSeconds() <= self::maximumNumberOfSeconds();
    return $isValid;
  }

  public static function minimumNumberOfSeconds()
  {
    return 1;
  }

  public static function maximumNumberOfSeconds()
  {
    return 5;
  }

  public function addSecond($aSecond)
  {
    $wasAdded = false;
    if ($this->indexOfSecond($aSecond) !== -1) { return false; }
    if ($this->numberOfSeconds() >= self::maximumNumberOfSeconds())
    {
      return $wasAdded;
    }

    $this->seconds[] = $aSecond;
    if ($aSecond->indexOfFirst($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aSecond->addFirst($this);
      if (!$wasAdded)
      {
        array_pop($this->seconds);
      }
    }
    return $wasAdded;
  }

  public function removeSecond($aSecond)
  {
    $wasRemoved = false;
    if ($this->indexOfSecond($aSecond) == -1)
    {
      return $wasRemoved;
    }

    if ($this->numberOfSeconds() <= self::minimumNumberOfSeconds())
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfSecond($aSecond);
    unset($this->seconds[$oldIndex]);
    if ($aSecond->indexOfFirst($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aSecond->removeFirst($this);
      if (!$wasRemoved)
      {
        $this->seconds[$oldIndex] = $aSecond;
        ksort($this->seconds);
      }
    }
    $this->seconds = array_values($this->seconds);
    return $wasRemoved;
  }

  public function setSeconds($newSeconds)
  {
    $wasSet = false;
    $verifiedSeconds = array();
    foreach ($newSeconds as $aSecond)
    {
      if (array_search($aSecond,$verifiedSeconds) !== false)
      {
        continue;
      }
      $verifiedSeconds[] = $aSecond;
    }

    if (count($verifiedSeconds) != count($newSeconds) || count($verifiedSeconds) < self::minimumNumberOfSeconds() || count($verifiedSeconds) > self::maximumNumberOfSeconds())
    {
      return $wasSet;
    }

    $oldSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($verifiedSeconds as $aNewSecond)
    {
      $this->seconds[] = $aNewSecond;
      $removeIndex = array_search($aNewSecond,$oldSeconds);
      if ($removeIndex !== false)
      {
        unset($oldSeconds[$removeIndex]);
        $oldSeconds = array_values($oldSeconds);
      }
      else
      {
        $aNewSecond->addFirst($this);
      }
    }

    foreach ($oldSeconds as $anOldSecond)
    {
      $anOldSecond->removeFirst($this);
    }
    $wasSet = true;
    return $wasSet;
  }

  public function addSecondAt($aSecond, $index)
  {  
    $wasAdded = false;
    if($this->addSecond($aSecond))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveSecondAt($aSecond, $index)
  {
    $wasAdded = false;
    if($this->indexOfSecond($aSecond) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addSecondAt($aSecond, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($copyOfSeconds as $aSecond)
    {
      $aSecond->removeFirst($this);
    }
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $seconds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct($allSeconds)
  {
    $this->seconds = array();
    $didAddSeconds = $this->setSeconds($allSeconds);
    if (!$didAddSeconds)
    {
      throw new Exception("Unable to create First, must have at least 1 seconds. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond_index($index)
  {
    $aSecond = $this->seconds[$index];
    return $aSecond;
  }

  public function getSeconds()
  {
    $newSeconds = $this->seconds;
    return $newSeconds;
  }

  public function numberOfSeconds()
  {
    $number = count($this->seconds);
    return $number;
  }

  public function hasSeconds()
  {
    $has = $this->numberOfSeconds() > 0;
    return $has;
  }

  public function indexOfSecond($aSecond)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->seconds as $second)
    {
      if ($second->equals($aSecond))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public function isNumberOfSecondsValid()
  {
    $isValid = $this->numberOfSeconds() >= self::minimumNumberOfSeconds();
    return $isValid;
  }

  public static function minimumNumberOfSeconds()
  {
    return 1;
  }

  public function addSecond($aSecond)
  {
    $wasAdded = false;
    if ($this->indexOfSecond($aSecond) !== -1) { return false; }
    $this->seconds[] = $aSecond;
    if ($aSecond->indexOfFirst($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aSecond->addFirst($this);
      if (!$wasAdded)
      {
        array_pop($this->seconds);
      }
    }
    return $wasAdded;
  }

  public function removeSecond($aSecond)
  {
    $wasRemoved = false;
    if ($this->indexOfSecond($aSecond) == -1)
    {
      return $wasRemoved;
    }

    if ($this->numberOfSeconds() <= self::minimumNumberOfSeconds())
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfSecond($aSecond);
    unset($this->seconds[$oldIndex]);
    if ($aSecond->indexOfFirst($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aSecond->removeFirst($this);
      if (!$wasRemoved)
      {
        $this->seconds[$oldIndex] = $aSecond;
        ksort($this->seconds);
      }
    }
    $this->seconds = array_values($this->seconds);
    return $wasRemoved;
  }

  public function setSeconds($newSeconds)
  {
    $wasSet = false;
    $verifiedSeconds = array();
    foreach ($newSeconds as $aSecond)
    {
      if (array_search($aSecond,$verifiedSeconds) !== false)
      {
        continue;
      }
      $verifiedSeconds[] = $aSecond;
    }

    if (count($verifiedSeconds) != count($newSeconds) || count($verifiedSeconds) < self::minimumNumberOfSeconds())
    {
      return $wasSet;
    }

    $oldSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($verifiedSeconds as $aNewSecond)
    {
      $this->seconds[] = $aNewSecond;
      $removeIndex = array_search($aNewSecond,$oldSeconds);
      if ($removeIndex !== false)
      {
        unset($oldSeconds[$removeIndex]);
        $oldSeconds = array_values($oldSeconds);
      }
      else
      {
        $aNewSecond->addFirst($this);
      }
    }

    foreach ($oldSeconds as $anOldSecond)
    {
      $anOldSecond->removeFirst($this);
    }
    $wasSet = true;
    return $wasSet;
  }

  public function addSecondAt($aSecond, $index)
  {  
    $wasAdded = false;
    if($this->addSecond($aSecond))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveSecondAt($aSecond, $index)
  {
    $wasAdded = false;
    if($this->indexOfSecond($aSecond) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addSecondAt($aSecond, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($copyOfSeconds as $aSecond)
    {
      $aSecond->removeFirst($this);
    }
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $seconds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct($allSeconds)
  {
    $this->seconds = array();
    $didAddSeconds = $this->setSeconds($allSeconds);
    if (!$didAddSeconds)
    {
      throw new Exception("Unable to create First, must have 5 seconds. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond_index($index)
  {
    $aSecond = $this->seconds[$index];
    return $aSecond;
  }

  public function getSeconds()
  {
    $newSeconds = $this->seconds;
    return $newSeconds;
  }

  public function numberOfSeconds()
  {
    $number = count($this->seconds);
    return $number;
  }

  public function hasSeconds()
  {
    $has = $this->numberOfSeconds() > 0;
    return $has;
  }

  public function indexOfSecond($aSecond)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->seconds as $second)
    {
      if ($second->equals($aSecond))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public function isNumberOfSecondsValid()
  {
    $isValid = $this->numberOfSeconds() >= self::minimumNumberOfSeconds() && $this->numberOfSeconds() <= self::maximumNumberOfSeconds();
    return $isValid;
  }

  public static function requiredNumberOfSeconds()
  {
    return 5;
  }

  public static function minimumNumberOfSeconds()
  {
    return 5;
  }

  public static function maximumNumberOfSeconds()
  {
    return 5;
  }

  public function addSecond($aSecond)
  {
    $wasAdded = false;
    if ($this->indexOfSecond($aSecond) !== -1) { return false; }
    if ($this->numberOfSeconds() >= self::maximumNumberOfSeconds())
    {
      return $wasAdded;
    }

    $this->seconds[] = $aSecond;
    if ($aSecond->indexOfFirst($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aSecond->addFirst($this);
      if (!$wasAdded)
      {
        array_pop($this->seconds);
      }
    }
    return $wasAdded;
  }

  public function removeSecond($aSecond)
  {
    $wasRemoved = false;
    if ($this->indexOfSecond($aSecond) == -1)
    {
      return $wasRemoved;
    }

    if ($this->numberOfSeconds() <= self::minimumNumberOfSeconds())
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfSecond($aSecond);
    unset($this->seconds[$oldIndex]);
    if ($aSecond->indexOfFirst($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aSecond->removeFirst($this);
      if (!$wasRemoved)
      {
        $this->seconds[$oldIndex] = $aSecond;
        ksort($this->seconds);
      }
    }
    $this->seconds = array_values($this->seconds);
    return $wasRemoved;
  }

  public function setSeconds($newSeconds)
  {
    $wasSet = false;
    $verifiedSeconds = array();
    foreach ($newSeconds as $aSecond)
    {
      if (array_search($aSecond,$verifiedSeconds) !== false)
      {
        continue;
      }
      $verifiedSeconds[] = $aSecond;
    }

    if (count($verifiedSeconds) != count($newSeconds) || count($verifiedSeconds) < self::minimumNumberOfSeconds() || count($verifiedSeconds) > self::maximumNumberOfSeconds())
    {
      return $wasSet;
    }

    $oldSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($verifiedSeconds as $aNewSecond)
    {
      $this->seconds[] = $aNewSecond;
      $removeIndex = array_search($aNewSecond,$oldSeconds);
      if ($removeIndex !== false)
      {
        unset($oldSeconds[$removeIndex]);
        $oldSeconds = array_values($oldSeconds);
      }
      else
      {
        $aNewSecond->addFirst($this);
      }
    }

    foreach ($oldSeconds as $anOldSecond)
    {
      $anOldSecond->removeFirst($this);
    }
    $wasSet = true;
    return $wasSet;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($copyOfSeconds as $aSecond)
    {
      $aSecond->removeFirst($this);
    }
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $seconds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct()
  {
    $this->seconds = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond_index($index)
  {
    $aSecond = $this->seconds[$index];
    return $aSecond;
  }

  public function getSeconds()
  {
    $newSeconds = $this->seconds;
    return $newSeconds;
  }

  public function numberOfSeconds()
  {
    $number = count($this->seconds);
    return $number;
  }

  public function hasSeconds()
  {
    $has = $this->numberOfSeconds() > 0;
    return $has;
  }

  public function indexOfSecond($aSecond)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->seconds as $second)
    {
      if ($second->equals($aSecond))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public static function minimumNumberOfSeconds()
  {
    return 0;
  }

  public static function maximumNumberOfSeconds()
  {
    return 5;
  }

  public function addSecond($aSecond)
  {
    $wasAdded = false;
    if ($this->indexOfSecond($aSecond) !== -1) { return false; }
    if ($this->numberOfSeconds() >= self::maximumNumberOfSeconds())
    {
      return $wasAdded;
    }

    $this->seconds[] = $aSecond;
    if ($aSecond->indexOfFirst($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aSecond->addFirst($this);
      if (!$wasAdded)
      {
        array_pop($this->seconds);
      }
    }
    return $wasAdded;
  }

  public function removeSecond($aSecond)
  {
    $wasRemoved = false;
    if ($this->indexOfSecond($aSecond) == -1)
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfSecond($aSecond);
    unset($this->seconds[$oldIndex]);
    if ($aSecond->indexOfFirst($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aSecond->removeFirst($this);
      if (!$wasRemoved)
      {
        $this->seconds[$oldIndex] = $aSecond;
        ksort($this->seconds);
      }
    }
    $this->seconds = array_values($this->seconds);
    return $wasRemoved;
  }

  public function setSeconds($newSeconds)
  {
    $wasSet = false;
    $verifiedSeconds = array();
    foreach ($newSeconds as $aSecond)
    {
      if (array_search($aSecond,$verifiedSeconds) !== false)
      {
        continue;
      }
      $verifiedSeconds[] = $aSecond;
    }

    if (count($verifiedSeconds) != count($newSeconds) || count($verifiedSeconds) > self::maximumNumberOfSeconds())
    {
      return $wasSet;
    }

    $oldSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($verifiedSeconds as $aNewSecond)
    {
      $this->seconds[] = $aNewSecond;
      $removeIndex = array_search($aNewSecond,$oldSeconds);
      if ($removeIndex !== false)
      {
        unset($oldSeconds[$removeIndex]);
        $oldSeconds = array_values($oldSeconds);
      }
      else
      {
        $aNewSecond->addFirst($this);
      }
    }

    foreach ($oldSeconds as $anOldSecond)
    {
      $anOldSecond->removeFirst($this);
    }
    $wasSet = true;
    return $wasSet;
  }

  public function addSecondAt($aSecond, $index)
  {  
    $wasAdded = false;
    if($this->addSecond($aSecond))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveSecondAt($aSecond, $index)
  {
    $wasAdded = false;
    if($this->indexOfSecond($aSecond) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addSecondAt($aSecond, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($copyOfSeconds as $aSecond)
    {
      $aSecond->removeFirst($this);
    }
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

  public function isNumberOfSecondsValid()
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $seconds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct()
  {
    $this->seconds = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond_index($index)
  {
    $aSecond = $this->seconds[$index];
    return $aSecond;
  }

  public function getSeconds()
  {
    $newSeconds = $this->seconds;
    return $newSeconds;
  }

  public function numberOfSeconds()
  {
    $number = count($this->seconds);
    return $number;
  }

  public function hasSeconds()
  {
    $has = $this->numberOfSeconds() > 0;
    return $has;
  }

  public function indexOfSecond($aSecond)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->seconds as $second)
    {
      if ($second->equals($aSecond))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public static function minimumNumberOfSeconds()
  {
    return 0;
  }

  public function addSecond($aSecond)
  {
    $wasAdded = false;
    if ($this->indexOfSecond($aSecond) !== -1) { return false; }
    $this->seconds[] = $aSecond;
    if ($aSecond->indexOfFirst($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aSecond->addFirst($this);
      if (!$wasAdded)
      {
        array_pop($this->seconds);
      }
    }
    return $wasAdded;
  }

  public function removeSecond($aSecond)
  {
    $wasRemoved = false;
    if ($this->indexOfSecond($aSecond) == -1)
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfSecond($aSecond);
    unset($this->seconds[$oldIndex]);
    if ($aSecond->indexOfFirst($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aSecond->removeFirst($this);
      if (!$wasRemoved)
      {
        $this->seconds[$oldIndex] = $aSecond;
        ksort($this->seconds);
      }
    }
    $this->seconds = array_values($this->seconds);
    return $wasRemoved;
  }

  public function addSecondAt($aSecond, $index)
  {  
    $wasAdded = false;
    if($this->addSecond($aSecond))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveSecondAt($aSecond, $index)
  {
    $wasAdded = false;
    if($this->indexOfSecond($aSecond) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addSecondAt($aSecond, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($copyOfSeconds as $aSecond)
    {
      $aSecond->removeFirst($this);
    }
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

  public function setSeconds(Second... $newSeconds)
  {
          return "";
  }

  public function isNumberOfSecondsValid()
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $second;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct($aSecond = null)
  {
    if (func_num_args() == 0) { return; }

    if ($aSecond == null || $aSecond->getFirst() != null)
    {
      throw new Exception("Unable to create First due to aSecond. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
    $this->second = $aSecond;
  }
  public static function newInstance()
  {
    $thisInstance = new First();
    $thisInstance->second = new Second($thisInstance);
    return $thisInstance;
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond()
  {
    return $this->second;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $existingSecond = $this->second;
    $this->second = null;
    if ($existingSecond != null)
    {
      $existingSecond->delete();
    }
  }

  public function addSecond(Second $aSecond)
  {
          return "";
  }

  public function getSeconds()
  {
          return "";
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

  public function setSeconds(Second... $newSeconds)
  {
          return "";
  }

  public function numberOfSeconds()
  {
          return "";
  }

  public function hasSeconds()
  {
          return "";
  }

  public function indexOfSecond(Second $second)
  {
          return "";
  }

  public function isNumberOfSecondsValid()
  {
          return "";
  }

  public function removeSecond(Second $second)
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $seconds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct()
  {
    $this->seconds = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond_index($index)
  {
    $aSecond = $this->seconds[$index];
    return $aSecond;
  }

  public function getSeconds()
  {
    $newSeconds = $this->seconds;
    return $newSeconds;
  }

  public function numberOfSeconds()
  {
    $number = count($this->seconds);
    return $number;
  }

  public function hasSeconds()
  {
    $has = $this->numberOfSeconds() > 0;
    return $has;
  }

  public function indexOfSecond($aSecond)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->seconds as $second)
    {
      if ($second->equals($aSecond))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public function isNumberOfSecondsValid()
  {
    $isValid = $this->numberOfSeconds() >= self::minimumNumberOfSeconds() && $this->numberOfSeconds() <= self::maximumNumberOfSeconds();
    return $isValid;
  }

  public static function requiredNumberOfSeconds()
  {
    return 5;
  }

  public static function minimumNumberOfSeconds()
  {
    return 5;
  }

  public static function maximumNumberOfSeconds()
  {
    return 5;
  }

  public function addSecond($aSecond)
  {
    $wasAdded = false;
    if ($this->indexOfSecond($aSecond) !== -1) { return false; }
    if ($this->numberOfSeconds() >= self::maximumNumberOfSeconds())
    {
      return $wasAdded;
    }

    $this->seconds[] = $aSecond;
    if ($aSecond->indexOfFirst($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aSecond->addFirst($this);
      if (!$wasAdded)
      {
        array_pop($this->seconds);
      }
    }
    return $wasAdded;
  }

  public function removeSecond($aSecond)
  {
    $wasRemoved = false;
    if ($this->indexOfSecond($aSecond) == -1)
    {
      return $wasRemoved;
    }

    if ($this->numberOfSeconds() <= self::minimumNumberOfSeconds())
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfSecond($aSecond);
    unset($this->seconds[$oldIndex]);
    if ($aSecond->indexOfFirst($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aSecond->removeFirst($this);
      if (!$wasRemoved)
      {
        $this->seconds[$oldIndex] = $aSecond;
        ksort($this->seconds);
      }
    }
    $this->seconds = array_values($this->seconds);
    return $wasRemoved;
  }

  public function setSeconds($newSeconds)
  {
    $wasSet = false;
    $verifiedSeconds = array();
    foreach ($newSeconds as $aSecond)
    {
      if (array_search($aSecond,$verifiedSeconds) !== false)
      {
        continue;
      }
      $verifiedSeconds[] = $aSecond;
    }

    if (count($verifiedSeconds) != count($newSeconds) || count($verifiedSeconds) < self::minimumNumberOfSeconds() || count($verifiedSeconds) > self::maximumNumberOfSeconds())
    {
      return $wasSet;
    }

    $oldSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($verifiedSeconds as $aNewSecond)
    {
      $this->seconds[] = $aNewSecond;
      $removeIndex = array_search($aNewSecond,$oldSeconds);
      if ($removeIndex !== false)
      {
        unset($oldSeconds[$removeIndex]);
        $oldSeconds = array_values($oldSeconds);
      }
      else
      {
        $aNewSecond->addFirst($this);
      }
    }

    foreach ($oldSeconds as $anOldSecond)
    {
      $anOldSecond->removeFirst($this);
    }
    $wasSet = true;
    return $wasSet;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($copyOfSeconds as $aSecond)
    {
      if ($aSecond->numberOfFirsts() <= Second::minimumNumberOfFirsts())
      {
        $aSecond->delete();
      }
      else
      {
        $aSecond->removeFirst($this);
      }
    }
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $seconds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct()
  {
    $this->seconds = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond_index($index)
  {
    $aSecond = $this->seconds[$index];
    return $aSecond;
  }

  public function getSeconds()
  {
    $newSeconds = $this->seconds;
    return $newSeconds;
  }

  public function numberOfSeconds()
  {
    $number = count($this->seconds);
    return $number;
  }

  public function hasSeconds()
  {
    $has = $this->numberOfSeconds() > 0;
    return $has;
  }

  public function indexOfSecond($aSecond)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->seconds as $second)
    {
      if ($second->equals($aSecond))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public function isNumberOfSecondsValid()
  {
    $isValid = $this->numberOfSeconds() >= self::minimumNumberOfSeconds() && $this->numberOfSeconds() <= self::maximumNumberOfSeconds();
    return $isValid;
  }

  public static function minimumNumberOfSeconds()
  {
    return 2;
  }

  public static function maximumNumberOfSeconds()
  {
    return 4;
  }

  public function addSecond($aSecond)
  {
    $wasAdded = false;
    if ($this->indexOfSecond($aSecond) !== -1) { return false; }
    if ($this->numberOfSeconds() >= self::maximumNumberOfSeconds())
    {
      return $wasAdded;
    }

    $this->seconds[] = $aSecond;
    if ($aSecond->indexOfFirst($this) != -1)
    {
      $wasAdded = true;
    }
    else
    {
      $wasAdded = $aSecond->addFirst($this);
      if (!$wasAdded)
      {
        array_pop($this->seconds);
      }
    }
    return $wasAdded;
  }

  public function removeSecond($aSecond)
  {
    $wasRemoved = false;
    if ($this->indexOfSecond($aSecond) == -1)
    {
      return $wasRemoved;
    }

    if ($this->numberOfSeconds() <= self::minimumNumberOfSeconds())
    {
      return $wasRemoved;
    }

    $oldIndex = $this->indexOfSecond($aSecond);
    unset($this->seconds[$oldIndex]);
    if ($aSecond->indexOfFirst($this) == -1)
    {
      $wasRemoved = true;
    }
    else
    {
      $wasRemoved = $aSecond->removeFirst($this);
      if (!$wasRemoved)
      {
        $this->seconds[$oldIndex] = $aSecond;
        ksort($this->seconds);
      }
    }
    $this->seconds = array_values($this->seconds);
    return $wasRemoved;
  }

  public function setSeconds($newSeconds)
  {
    $wasSet = false;
    $verifiedSeconds = array();
    foreach ($newSeconds as $aSecond)
    {
      if (array_search($aSecond,$verifiedSeconds) !== false)
      {
        continue;
      }
      $verifiedSeconds[] = $aSecond;
    }

    if (count($verifiedSeconds) != count($newSeconds) || count($verifiedSeconds) < self::minimumNumberOfSeconds() || count($verifiedSeconds) > self::maximumNumberOfSeconds())
    {
      return $wasSet;
    }

    $oldSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($verifiedSeconds as $aNewSecond)
    {
      $this->seconds[] = $aNewSecond;
      $removeIndex = array_search($aNewSecond,$oldSeconds);
      if ($removeIndex !== false)
      {
        unset($oldSeconds[$removeIndex]);
        $oldSeconds = array_values($oldSeconds);
      }
      else
      {
        $aNewSecond->addFirst($this);
      }
    }

    foreach ($oldSeconds as $anOldSecond)
    {
      $anOldSecond->removeFirst($this);
    }
    $wasSet = true;
    return $wasSet;
  }

  public function addSecondAt($aSecond, $index)
  {  
    $wasAdded = false;
    if($this->addSecond($aSecond))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveSecondAt($aSecond, $index)
  {
    $wasAdded = false;
    if($this->indexOfSecond($aSecond) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addSecondAt($aSecond, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    $copyOfSeconds = $this->seconds;
    $this->seconds = array();
    foreach ($copyOfSeconds as $aSecond)
    {
      if ($aSecond->numberOfFirsts() <= Second::minimumNumberOfFirsts())
      {
        $aSecond->delete();
      }
      else
      {
        $aSecond->removeFirst($this);
      }
    }
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

}
?>
<?php
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

class First implements I
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //First Associations
  private $seconds;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public function __construct()
  {
    $this->seconds = array();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public function getSecond_index($index)
  {
    $aSecond = $this->seconds[$index];
    return $aSecond;
  }

  public function getSeconds()
  {
    $newSeconds = $this->seconds;
    return $newSeconds;
  }

  public function numberOfSeconds()
  {
    $number = count($this->seconds);
    return $number;
  }

  public function hasSeconds()
  {
    $has = $this->numberOfSeconds() > 0;
    return $has;
  }

  public function indexOfSecond($aSecond)
  {
    $wasFound = false;
    $index = 0;
    foreach($this->seconds as $second)
    {
      if ($second->equals($aSecond))
      {
        $wasFound = true;
        break;
      }
      $index += 1;
    }
    $index = $wasFound ? $index : -1;
    return $index;
  }

  public function isNumberOfSecondsValid()
  {
    $isValid = $this->numberOfSeconds() >= self::minimumNumberOfSeconds() && $this->numberOfSeconds() <= self::maximumNumberOfSeconds();
    return $isValid;
  }

  public static function minimumNumberOfSeconds()
  {
    return 1;
  }

  public static function maximumNumberOfSeconds()
  {
    return 4;
  }

  public function addSecondVia()
  {
    if ($this->numberOfSeconds() >= self::maximumNumberOfSeconds())
    {
      return null;
    }
    else
    {
      return new Second($this);
    }
  }

  public function addSecond($aSecond)
  {
    $wasAdded = false;
    if ($this->indexOfSecond($aSecond) !== -1) { return false; }
    if ($this->numberOfSeconds() >= self::maximumNumberOfSeconds())
    {
      return $wasAdded;
    }

    $existingFirst = $aSecond->getFirst();
    $isNewFirst = $existingFirst != null && $this !== $existingFirst;

    if ($isNewFirst && $existingFirst->numberOfSeconds() <= self::minimumNumberOfSeconds())
    {
      return $wasAdded;
    }

    if ($isNewFirst)
    {
      $aSecond->setFirst($this);
    }
    else
    {
      $this->seconds[] = $aSecond;
    }
    $wasAdded = true;
    return $wasAdded;
  }

  public function removeSecond($aSecond)
  {
    $wasRemoved = false;
    //Unable to remove aSecond, as it must always have a first
    if ($this === $aSecond->getFirst())
    {
      return $wasRemoved;
    }

    //first already at minimum (1)
    if ($this->numberOfSeconds() <= self::minimumNumberOfSeconds())
    {
      return $wasRemoved;
    }

    unset($this->seconds[$this->indexOfSecond($aSecond)]);
    $this->seconds = array_values($this->seconds);
    $wasRemoved = true;
    return $wasRemoved;
  }

  public function addSecondAt($aSecond, $index)
  {  
    $wasAdded = false;
    if($this->addSecond($aSecond))
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    }
    return $wasAdded;
  }

  public function addOrMoveSecondAt($aSecond, $index)
  {
    $wasAdded = false;
    if($this->indexOfSecond($aSecond) !== -1)
    {
      if($index < 0 ) { $index = 0; }
      if($index > $this->numberOfSeconds()) { $index = $this->numberOfSeconds() - 1; }
      array_splice($this->seconds, $this->indexOfSecond($aSecond), 1);
      array_splice($this->seconds, $index, 0, array($aSecond));
      $wasAdded = true;
    } 
    else 
    {
      $wasAdded = $this->addSecondAt($aSecond, $index);
    }
    return $wasAdded;
  }

  public function equals($compareTo)
  {
    return $this == $compareTo;
  }

  public function delete()
  {
    foreach ($this->seconds as $aSecond)
    {
      $aSecond->delete();
    }
  }

  public function setSecond(Second $aSecond)
  {
          return "";
  }

  public function setSeconds(Second... $newSeconds)
  {
          return "";
  }

}
?>