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

DirectiveNode::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Language\Node;
4
5
use Digia\GraphQL\Language\Location;
6
7
class DirectiveNode extends AbstractNode implements ArgumentsAwareInterface, NameAwareInterface
8
{
9
    use NameTrait;
10
    use ArgumentsTrait;
11
12
    /**
13
     * DirectiveNode constructor.
14
     *
15
     * @param NameNode       $name
16
     * @param ArgumentNode[] $arguments
17
     * @param Location|null  $location
18
     */
19
    public function __construct(NameNode $name, array $arguments, ?Location $location)
20
    {
21
        parent::__construct(NodeKindEnum::DIRECTIVE, $location);
22
23
        $this->name      = $name;
24
        $this->arguments = $arguments;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function toAST(): array
31
    {
32
        return [
33
            'kind'      => $this->kind,
34
            'name'      => $this->getNameAST(),
35
            'arguments' => $this->getArgumentsAST(),
36
            'location'  => $this->getLocationAST(),
37
        ];
38
    }
39
}
40