Completed
Pull Request — master (#148)
by Christoffer
04:19
created

InterfaceTypeDefinitionASTBuilder::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 2
1
<?php
2
3
namespace Digia\GraphQL\Language\ASTBuilder;
4
5
use Digia\GraphQL\Language\KeywordEnum;
6
use Digia\GraphQL\Language\LexerInterface;
7
use Digia\GraphQL\Language\Node\NodeKindEnum;
8
9
class InterfaceTypeDefinitionASTBuilder extends AbstractASTBuilder
10
{
11
    /**
12
     * @inheritdoc
13
     */
14
    public function supportsBuilder(string $kind): bool
15
    {
16
        return $kind === ASTKindEnum::INTERFACE_TYPE_DEFINITION;
17
    }
18
19
    /**
20
     * @inheritdoc
21
     */
22
    public function build(LexerInterface $lexer, array $params): ?array
23
    {
24
        $start = $lexer->getToken();
25
26
        $description = $this->buildAST(ASTKindEnum::DESCRIPTION, $lexer);
27
28
        $this->expectKeyword($lexer, KeywordEnum::INTERFACE);
29
30
        return [
31
            'kind'        => NodeKindEnum::INTERFACE_TYPE_DEFINITION,
32
            'description' => $description,
33
            'name'        => $this->buildAST(ASTKindEnum::NAME, $lexer),
34
            'directives'  => $this->buildAST(ASTKindEnum::DIRECTIVES, $lexer),
35
            'fields'      => $this->buildAST(ASTKindEnum::FIELDS_DEFINITION, $lexer),
36
            'loc'         => $this->buildLocation($lexer, $start),
37
        ];
38
    }
39
}
40