Esempio n. 1
0
 /**
  * @param WordsIterator $iterator
  * @return string
  */
 public function getNextWord(WordsIterator $iterator)
 {
     $word = '';
     while ($iterator->valid()) {
         if (!preg_match("/^{$this->getBasePattern()}\$/", $this->text[$iterator->current()])) {
             if ($this->matchWord($word)) {
                 break;
             }
             $word = '';
             $iterator->next();
             continue;
         }
         $word .= $this->text[$iterator->current()];
         $iterator->next();
     }
     return $word;
 }
 public function testRewind()
 {
     $iterator = new WordsIterator(new Words('text text'));
     $iterator->next();
     $iterator->next();
     $iterator->next();
     $iterator->next();
     $iterator->next();
     $iterator->next();
     $this->assertTrue($iterator->valid());
     $iterator->rewind();
     $this->assertEquals(0, $iterator->current());
 }