Completed
Push — master ( 7faae5...9f7b4d )
by Christoffer
02:27
created

DirectiveDefinitionNode   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 9 1
A getLocations() 0 3 1
A getLocationsAsArray() 0 5 1
1
<?php
2
3
namespace Digia\GraphQL\Language\AST\Node;
4
5
use Digia\GraphQL\Contract\SerializationInterface;
6
use Digia\GraphQL\Language\AST\Node\Behavior\ArgumentsTrait;
7
use Digia\GraphQL\Language\AST\Node\Behavior\DescriptionTrait;
8
use Digia\GraphQL\Language\AST\Node\Behavior\NameTrait;
9
use Digia\GraphQL\Language\AST\Node\Contract\DefinitionNodeInterface;
10
use Digia\GraphQL\Language\AST\NodeKindEnum;
11
12
class DirectiveDefinitionNode extends AbstractNode implements DefinitionNodeInterface
13
{
14
15
    use DescriptionTrait;
16
    use NameTrait;
17
    use ArgumentsTrait;
18
19
    /**
20
     * @var string
21
     */
22
    protected $kind = NodeKindEnum::DIRECTIVE_DEFINITION;
23
24
    /**
25
     * @var NameNode[]
26
     */
27
    protected $locations;
28
29
    /**
30
     * @return NameNode[]
31
     */
32
    public function getLocations(): array
33
    {
34
        return $this->locations;
35
    }
36
37
    /**
38
     * @return array
39
     */
40
    public function getLocationsAsArray(): array
41
    {
42
        return array_map(function (SerializationInterface $node) {
43
            return $node->toArray();
44
        }, $this->locations);
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function toArray(): array
51
    {
52
        return [
53
            'kind'        => $this->kind,
54
            'description' => $this->getDescriptionAsArray(),
55
            'name'        => $this->getNameAsArray(),
56
            'arguments'   => $this->getArgumentsAsArray(),
57
            'locations'   => $this->getLocationsAsArray(),
58
            'loc'         => $this->getLocationAsArray(),
59
        ];
60
    }
61
}
62