Automattic\WooCommerce\Vendor\GraphQL\Language

Parser::expectOptionalKeywordprivateWC 1.0

If the next token is a given keyword, return "true" after advancing the lexer. Otherwise, do not change the parser state and return "false".

Method of the class: Parser{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->expectOptionalKeyword( $value ): bool;
$value(string) (required)
.

Parser::expectOptionalKeyword() code WC 11.0.1

private function expectOptionalKeyword(string $value): bool
{
    $token = $this->lexer->token;
    if ($token->kind === Token::NAME && $token->value === $value) {
        $this->lexer->advance();

        return true;
    }

    return false;
}