Passed
Push — master ( c47e08...96e565 )
by Quang
02:51
created

ArgumentsDefinitionASTBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsBuilder() 0 3 1
A build() 0 14 2
1
<?php
2
3
namespace Digia\GraphQL\Language\ASTBuilder;
4
5
use Digia\GraphQL\Language\LexerInterface;
6
use Digia\GraphQL\Language\TokenKindEnum;
7
8
class ArgumentsDefinitionASTBuilder extends AbstractASTBuilder
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function supportsBuilder(string $kind): bool
14
    {
15
        return $kind === ASTKindEnum::ARGUMENTS_DEFINITION;
16
    }
17
18
    /**
19
     * @inheritdoc
20
     */
21
    public function build(LexerInterface $lexer, array $params): ?array
22
    {
23
        $parseFunction = function (LexerInterface $lexer): array {
24
            return $this->buildAST(ASTKindEnum::INPUT_VALUE_DEFINITION, $lexer);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->buildAST(D...LUE_DEFINITION, $lexer) could return the type null which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
25
        };
26
27
        return $this->peek($lexer, TokenKindEnum::PAREN_L)
28
            ? $this->many(
29
                $lexer,
30
                TokenKindEnum::PAREN_L,
31
                $parseFunction,
32
                TokenKindEnum::PAREN_R
33
            )
34
            : [];
35
    }
36
}
37