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

FragmentDefinitionNode::toAST()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 10
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 FragmentDefinitionNode extends AbstractNode implements ExecutableDefinitionNodeInterface,
8
    DirectivesAwareInterface, NameAwareInterface
9
{
10
    use NameTrait;
11
    use VariableDefinitionsTrait;
12
    use TypeConditionTrait;
13
    use DirectivesTrait;
14
    use SelectionSetTrait;
15
16
    /**
17
     * FragmentDefinitionNode constructor.
18
     *
19
     * @param NameNode                 $name
20
     * @param VariableDefinitionNode[] $variableDefinitions
21
     * @param NamedTypeNode|null       $typeCondition
22
     * @param DirectiveNode[]          $directives
23
     * @param SelectionSetNode|null    $selectionSet
24
     * @param Location|null            $location
25
     */
26
    public function __construct(
27
        NameNode $name,
28
        array $variableDefinitions,
29
        ?NamedTypeNode $typeCondition,
30
        array $directives,
31
        ?SelectionSetNode $selectionSet,
32
        ?Location $location
33
    ) {
34
        parent::__construct(NodeKindEnum::FRAGMENT_DEFINITION, $location);
35
36
        $this->name                = $name;
37
        $this->variableDefinitions = $variableDefinitions;
38
        $this->typeCondition       = $typeCondition;
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
            'name'                => $this->getNameAST(),
51
            'variableDefinitions' => $this->getVariableDefinitionsAST(),
52
            'typeCondition'       => $this->getTypeConditionAST(),
53
            'directives'          => $this->getDirectivesAST(),
54
            'selectionSet'        => $this->getSelectionSetAST(),
55
            'loc'                 => $this->getLocationAST(),
56
        ];
57
    }
58
}
59