Passed
Push — master ( 22d357...2883c4 )
by Christoffer
02:52
created

FieldNode   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A toAST() 0 10 1
1
<?php
2
3
namespace Digia\GraphQL\Language\Node;
4
5
use Digia\GraphQL\Language\Location;
6
7
class FieldNode extends AbstractNode implements SelectionNodeInterface, ArgumentsAwareInterface,
8
    DirectivesAwareInterface, NameAwareInterface
9
{
10
    use NameTrait;
11
    use AliasTrait;
12
    use ArgumentsTrait;
13
    use DirectivesTrait;
14
    use SelectionSetTrait;
15
16
    /**
17
     * FieldNode constructor.
18
     *
19
     * @param NameNode|null         $alias
20
     * @param NameNode              $name
21
     * @param ArgumentNode[]        $arguments
22
     * @param DirectiveNode[]       $directives
23
     * @param SelectionSetNode|null $selectionSet
24
     * @param Location|null         $location
25
     */
26
    public function __construct(
27
        ?NameNode $alias,
28
        NameNode $name,
29
        array $arguments,
30
        array $directives,
31
        ?SelectionSetNode $selectionSet,
32
        ?Location $location
33
    ) {
34
        parent::__construct(NodeKindEnum::FIELD, $location);
35
36
        $this->alias        = $alias;
37
        $this->name         = $name;
38
        $this->arguments    = $arguments;
39
        $this->directives   = $directives;
40
        $this->selectionSet = $selectionSet;
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46
    public function toAST(): array
47
    {
48
        return [
49
            'kind'         => $this->kind,
50
            'loc'          => $this->getLocationAST(),
51
            'alias'        => $this->getAliasAST(),
52
            'name'         => $this->getNameAST(),
53
            'arguments'    => $this->getArgumentsAST(),
54
            'directives'   => $this->getDirectivesAST(),
55
            'selectionSet' => $this->getSelectionSetAST(),
56
        ];
57
    }
58
}
59