Exemplo n.º 1
0
 /**
  * Move to specific position
  *
  * @param Token $token
  * @return Token|null
  */
 public function moveToToken(Token $token)
 {
     if (!$token->isValid()) {
         $this->setValid(false);
         return new Token();
     }
     $tokenIndex = $token->getIndex();
     foreach ($this->collection as $index => $collectionToken) {
         if ($collectionToken->getIndex() == $tokenIndex) {
             $this->setPosition($index);
             return $collectionToken;
         }
     }
     $this->setValid(false);
     return new Token();
 }