Passed
Pull Request — master (#233)
by Christoffer
03:30
created

DirectiveDefinitionNode::getLocations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Digia\GraphQL\Language\Node;
4
5
use Digia\GraphQL\Language\Location;
6
7
class DirectiveDefinitionNode extends AbstractNode implements DefinitionNodeInterface, NameAwareInterface
8
{
9
    use DescriptionTrait;
10
    use NameTrait;
11
    use InputArgumentsTrait;
12
13
    /**
14
     * @var NameNode[]
15
     */
16
    protected $locations;
17
18
    /**
19
     * DirectiveDefinitionNode constructor.
20
     *
21
     * @param StringValueNode|null $description
22
     * @param NameNode             $name
23
     * @param ArgumentNode[]       $arguments
24
     * @param NameNode[]           $locations
25
     * @param Location|null        $location
26
     */
27
    public function __construct(
28
        ?StringValueNode $description,
29
        NameNode $name,
30
        array $arguments,
31
        array $locations,
32
        ?Location $location
33
    ) {
34
        parent::__construct(NodeKindEnum::DIRECTIVE_DEFINITION, $location);
35
36
        $this->description = $description;
37
        $this->name        = $name;
38
        $this->arguments   = $arguments;
0 ignored issues
show
Documentation Bug introduced by
It seems like $arguments of type Digia\GraphQL\Language\Node\ArgumentNode[] is incompatible with the declared type Digia\GraphQL\Language\N...utValueDefinitionNode[] of property $arguments.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
39
        $this->locations   = $locations;
40
    }
41
42
    /**
43
     * @return NameNode[]
44
     */
45
    public function getLocations(): array
46
    {
47
        return $this->locations;
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    public function getLocationsAST(): array
54
    {
55
        return \array_map(function (NameNode $node) {
56
            return $node->toAST();
57
        }, $this->locations);
58
    }
59
60
    /**
61
     * @param NameNode[] $locations
62
     * @return $this
63
     */
64
    public function setLocations(array $locations)
65
    {
66
        $this->locations = $locations;
67
        return $this;
68
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73
    public function toAST(): array
74
    {
75
        return [
76
            'kind'        => $this->kind,
77
            'description' => $this->getDescriptionAST(),
78
            'name'        => $this->getNameAST(),
79
            'arguments'   => $this->getArgumentsAST(),
80
            'locations'   => $this->getLocationsAST(),
81
            'loc'         => $this->getLocationAST(),
82
        ];
83
    }
84
}
85