Passed
Pull Request — master (#19)
by Christoffer
02:11
created

DirectiveDefinitionBuilder::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Language\AST\Node\Builder;
4
5
use Digia\GraphQL\Language\AST\Node\Contract\NodeInterface;
6
use Digia\GraphQL\Language\AST\Node\DirectiveDefinitionNode;
7
use Digia\GraphQL\Language\AST\NodeKindEnum;
8
9
class DirectiveDefinitionBuilder extends AbstractBuilder
10
{
11
12
    /**
13
     * @inheritdoc
14
     */
15
    public function build(array $ast): NodeInterface
16
    {
17
        return new DirectiveDefinitionNode([
18
            'description' => $this->buildOne($ast, 'description'),
19
            'name'        => $this->buildOne($ast, 'name'),
20
            'arguments'   => $this->buildMany($ast, 'arguments'),
21
            'locations'   => $this->buildMany($ast, 'locations'),
22
            'location'    => $this->createLocation($ast),
23
        ]);
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function supportsKind(string $kind): bool
30
    {
31
        return $kind === NodeKindEnum::DIRECTIVE_DEFINITION;
32
    }
33
}
34