Passed
Pull Request — master (#145)
by Christoffer
03:59 queued 01:32
created

NameASTBuilder::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace Digia\GraphQL\Language\ASTBuilder;
4
5
use Digia\GraphQL\Language\LexerInterface;
6
use Digia\GraphQL\Language\Node\NodeKindEnum;
7
use Digia\GraphQL\Language\TokenKindEnum;
8
9
class NameASTBuilder extends AbstractASTBuilder
10
{
11
    /**
12
     * @inheritdoc
13
     */
14
    public function supportsBuilder(string $kind): bool
15
    {
16
        return $kind === ASTKindEnum::NAME;
17
    }
18
19
    /**
20
     * @inheritdoc
21
     */
22
    public function build(LexerInterface $lexer, array $params): ?array
23
    {
24
        $token = $this->expect($lexer, TokenKindEnum::NAME);
25
26
        return [
27
            'kind'  => NodeKindEnum::NAME,
28
            'value' => $token->getValue(),
29
            'loc'   => $this->buildLocation($lexer, $token),
30
        ];
31
    }
32
}
33