| Conditions | 7 |
| Paths | 7 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function build(LexerInterface $lexer, array $params): ?array |
||
| 24 | { |
||
| 25 | if ($this->peek($lexer, TokenKindEnum::NAME)) { |
||
| 26 | // valid names are: query, mutation, subscription and fragment |
||
| 27 | switch ($lexer->getToken()->getValue()) { |
||
| 28 | case KeywordEnum::QUERY: |
||
| 29 | case KeywordEnum::MUTATION: |
||
| 30 | case KeywordEnum::SUBSCRIPTION: |
||
| 31 | return $this->buildAST(ASTKindEnum::OPERATION_DEFINITION, $lexer); |
||
| 32 | case KeywordEnum::FRAGMENT: |
||
| 33 | return $this->buildAST(ASTKindEnum::FRAGMENT_DEFINITION, $lexer); |
||
| 34 | } |
||
| 35 | } elseif ($this->peek($lexer, TokenKindEnum::BRACE_L)) { |
||
| 36 | // Anonymous query |
||
| 37 | return $this->buildAST(ASTKindEnum::OPERATION_DEFINITION, $lexer); |
||
| 38 | } |
||
| 39 | |||
| 40 | throw $this->unexpected($lexer); |
||
| 41 | } |
||
| 43 |