GraphQL\Language\Parser::expectKeyword PHP Method

expectKeyword() public method

If the next token is a keyword with the given value, return that token after advancing the parser. Otherwise, do not change the parser state and return false.
public expectKeyword ( string $value ) : Token
$value string
return Token
    function expectKeyword($value)
    {
        $token = $this->lexer->token;
        if ($token->kind === Token::NAME && $token->value === $value) {
            $this->lexer->advance();
            return $token;
        }
        throw new SyntaxError($this->lexer->source, $token->start, 'Expected "' . $value . '", found ' . $token->getDescription());
    }