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

DocumentBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsKind() 0 3 1
A build() 0 5 1
1
<?php
2
3
namespace Digia\GraphQL\Language\AST\Node\Builder;
4
5
use Digia\GraphQL\Language\AST\Node\Contract\DefinitionNodeInterface;
6
use Digia\GraphQL\Language\AST\Node\Contract\NodeInterface;
7
use Digia\GraphQL\Language\AST\Node\DocumentNode;
8
use Digia\GraphQL\Language\AST\NodeKindEnum;
9
10
class DocumentBuilder extends AbstractBuilder
11
{
12
13
    /**
14
     * @inheritdoc
15
     */
16
    public function build(array $ast): NodeInterface
17
    {
18
        return new DocumentNode([
19
            'definitions' => $this->buildMany($ast, 'definitions'),
20
            'location'    => $this->createLocation($ast),
21
        ]);
22
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function supportsKind(string $kind): bool
28
    {
29
        return $kind === NodeKindEnum::DOCUMENT;
30
    }
31
}
32