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

InlineFragmentNode::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
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 InlineFragmentNode extends AbstractNode implements FragmentNodeInterface, SelectionNodeInterface
8
{
9
    use DirectivesTrait;
10
    use TypeConditionTrait;
11
    use SelectionSetTrait;
12
13
    /**
14
     * InlineFragmentNode constructor.
15
     *
16
     * @param NamedTypeNode|null    $typeCondition
17
     * @param DirectiveNode[]       $directives
18
     * @param SelectionSetNode|null $selectionSet
19
     * @param Location|null         $location
20
     */
21
    public function __construct(
22
        ?NamedTypeNode $typeCondition,
23
        array $directives,
24
        ?SelectionSetNode $selectionSet,
25
        ?Location $location
26
    ) {
27
        parent::__construct(NodeKindEnum::INLINE_FRAGMENT, $location);
28
29
        $this->typeCondition = $typeCondition;
30
        $this->directives    = $directives;
31
        $this->selectionSet  = $selectionSet;
32
    }
33
34
    /**
35
     * @inheritdoc
36
     */
37
    public function toAST(): array
38
    {
39
        return [
40
            'kind'          => $this->kind,
41
            'typeCondition' => $this->getTypeConditionAST(),
42
            'directives'    => $this->getDirectivesAST(),
43
            'selectionSet'  => $this->getSelectionSetAST(),
44
            'loc'           => $this->getLocationAST(),
45
        ];
46
    }
47
}
48