Beispiel #1
0
 public function testSeeder()
 {
     $seeder = new Seeder('abc123');
     $this->assertEquals(0, $seeder->getPosition());
     $this->assertEquals(6, $seeder->getLength());
     $this->assertTrue($seeder->sof());
     $this->assertFalse($seeder->eof());
     $this->assertEquals('abc123', $seeder->get(6));
     $this->assertEquals('abc123', $seeder->get(1000));
     $this->assertEquals('abc', $seeder->get(3));
     $this->assertEquals('a', $seeder->get());
     $seeder->forward();
     $this->assertEquals('b', $seeder->get());
     $seeder->forward();
     $this->assertEquals('c', $seeder->get());
     $seeder->forward(2);
     $this->assertEquals('2', $seeder->get());
     $seeder->backward(2);
     $this->assertEquals('c', $seeder->get());
     $seeder->backward();
     $this->assertEquals('b', $seeder->get());
     $seeder->forward(4);
     $this->assertFalse($seeder->eof());
     $seeder->forward(1);
     $this->assertTrue($seeder->eof());
 }
Beispiel #2
0
 /**
  * @param Seeder $seeder
  * @return bool
  */
 protected static function parseOpen(Seeder $seeder)
 {
     if ('//' == $seeder->get(2)) {
         if (!$seeder->sof()) {
             $offset = 0;
             while (true) {
                 $offset++;
                 $seeder->backward();
                 if ($seeder->sof() || "\n" == $seeder->get() || "\r" == $seeder->get()) {
                     $seeder->forward($offset);
                     break;
                 }
                 if (' ' != $seeder->get() && "\t" != $seeder->get()) {
                     $seeder->forward($offset);
                     return false;
                 }
             }
         }
         $seeder->forward(2);
         self::trackEOF($seeder);
         return true;
     }
     return false;
 }