Esempio n. 1
0
 /**
  * Parses, formats and prints the next chunk
  *
  * @since 1.0
  * @uses  Parser::parse()
  * @uses  printEvent()
  * @uses  printDelta()
  * @uses  printTrackHeader()
  * @uses  printFileHeader()
  * @uses  printEof()
  * @uses  printData()
  * 
  * @return bool true if there is more to parse, false if EOF has been reached
  */
 public function printNext()
 {
     $totalTime = microtime(true);
     $parseTime = $totalTime;
     $chunk = $this->parser->parse();
     $this->parseTime += microtime(true) - $parseTime;
     $notEof = true;
     if ($chunk !== null) {
         if ($chunk instanceof Delta) {
             $this->printDelta($chunk);
         } else {
             if ($chunk instanceof Event) {
                 $this->printEvent($chunk);
             } else {
                 if ($chunk instanceof TrackHeader) {
                     $this->printTrackHeader($chunk);
                 } else {
                     if ($chunk instanceof FileHeader) {
                         $this->printFileHeader($chunk);
                     }
                 }
             }
         }
     } else {
         $this->printEof();
         $notEof = false;
     }
     $this->totalTime += microtime(true) - $totalTime;
     return $notEof;
 }
Esempio n. 2
0
 /**
  * Constructor
  *
  * The parse state is initialized to {@link ParseState::FILE_HEADER}.
  *
  * @since 1.0
  * @uses  setState()
  * 
  * @param  TrackParser $trackParser
  */
 public function __construct(TrackParser $trackParser = null)
 {
     parent::__construct();
     $this->trackParser = $trackParser === null ? new TrackParser() : $trackParser;
     $this->tracksParsed = 0;
     $this->tracksExpected = 0;
     $this->setState(ParseState::FILE_HEADER);
 }
Esempio n. 3
0
 /**
  * @since 1.0
  *
  * @param EventFactory $eventFactory
  */
 public function __construct(EventFactory $eventFactory = null)
 {
     parent::__construct();
     $this->continuationEvent = null;
     $this->eventFactory = $eventFactory ?: new EventFactory();
 }
Esempio n. 4
0
 public function testDefaultState()
 {
     $this->assertEquals(ParseState::EOF, $this->obj->getState());
 }