You are here

protected function Tokenizer::readUntilSequence in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php \Masterminds\HTML5\Parser\Tokenizer::readUntilSequence()

Read from the input stream until we get to the desired sequene or hit the end of the input stream.

1 call to Tokenizer::readUntilSequence()
Tokenizer::rawText in vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php
Read text in RAW mode.

File

vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php, line 893

Class

Tokenizer
The HTML5 tokenizer.

Namespace

Masterminds\HTML5\Parser

Code

protected function readUntilSequence($sequence) {
  $buffer = '';

  // Optimization for reading larger blocks faster.
  $first = substr($sequence, 0, 1);
  while ($this->scanner
    ->current() !== false) {
    $buffer .= $this->scanner
      ->charsUntil($first);

    // Stop as soon as we hit the stopping condition.
    if ($this
      ->sequenceMatches($sequence, false)) {
      return $buffer;
    }
    $buffer .= $this->scanner
      ->current();
    $this->scanner
      ->next();
  }

  // If we get here, we hit the EOF.
  $this
    ->parseError("Unexpected EOF during text read.");
  return $buffer;
}