private function matches(string $expected, bool $shouldConsume = true, int $cursor = null) : bool
    {
        $stream = $this->getStream($cursor);
        $expectedLength = strlen($expected);

        if (substr($stream, 0, $expectedLength) == $expected) {
            if ($shouldConsume) {
                $this->cursor += $expectedLength;
            }

            return true;
        }

        return false;
    }