public function match(SequenceInterface $sequence) { while (!$sequence->endOfSequence()) { $sequence->next(); $this->tokens[] = $sequence->current(); } }
public function match(SequenceInterface $sequence) { if ($sequence->endOfSequence()) { throw new ExpectationNotMatched(); } $nextToken = $sequence->peek(); if ($nextToken['code'] === $this->code) { if ($this->content === null || $this->content === $nextToken['content']) { $sequence->next(); return; } } throw new ExpectationNotMatched(); }