src/JmesPath/Lexer.php
private function matchOr(array &$chars, $current, $expected, $type, $orElse)
    {
        if (next($chars) === $expected) {
            next($chars);
            return [
                'type'  => $type,
                'pos'   => key($chars) - 1,
                'value' => $current . $expected
            ];
        }

        return [
            'type'  => $orElse,
            'pos'   => key($chars) - 1,
            'value' => $current
        ];
    }
private function matchOr(array &$chars, $current, $expected, $type, $orElse)
    {
        if (next($chars) === $expected) {
            next($chars);
            return [
                'type'  => $type,
                'pos'   => key($chars) - 1,
                'value' => $current . $expected
            ];
        }

        return [
            'type'  => $orElse,
            'pos'   => key($chars) - 1,
            'value' => $current
        ];
    }
Returns a token based on whether or not the next token matches the
expected value. If it does, a token of "$type" is returned. Otherwise,
a token of "$orElse" type is returned.

@param array  $chars    Array of characters by reference.
@param string $current  The current character.
@param string $expected Expected character.
@param string $type     Expected result type.
@param string $orElse   Otherwise return a token of this type.

@return array Returns a conditional token.