Skip to content

Commit

Permalink
Added support for parsing BOM signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
waltertamboer committed Nov 23, 2019
1 parent 67fa14b commit df2c97f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Splitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,16 @@ public function split(callable $callback): int
return $result;
}

private function parseLimbo(string $line)
private function parseLimbo(string $line): void
{
if (trim($line) === '') {
return;
}

if (strlen($line) >= 3 && $line[0] === "\xEF" && $line[1] === "\xBB" && $line[2] === "\xBF") {
$line = substr($line, 3);
}

if ($line[0] === '[') {
$this->buffer .= $line;
$this->state = self::STATE_TAGS;
Expand All @@ -129,7 +133,7 @@ private function parseLimbo(string $line)
}
}

private function parseTags(callable $callback, int &$result, string $line)
private function parseTags(callable $callback, int &$result, string $line): void
{
if ($line[0] === '[') {
$this->buffer .= $line;
Expand All @@ -150,7 +154,7 @@ private function parseTags(callable $callback, int &$result, string $line)
$this->state = self::STATE_MOVES;
}

private function parseMoves(callable $callback, int &$result, string $line)
private function parseMoves(callable $callback, int &$result, string $line): void
{
if ($line === "\n") {
$this->state = self::STATE_LIMBO;
Expand Down

0 comments on commit df2c97f

Please sign in to comment.