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

UnionTypeExtensionNode::toAST()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
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 UnionTypeExtensionNode extends AbstractNode implements TypeExtensionNodeInterface, DirectivesAwareInterface,
8
    NameAwareInterface
9
{
10
    use NameTrait;
11
    use DirectivesTrait;
12
    use TypesTrait;
13
14
    /**
15
     * UnionTypeExtensionNode constructor.
16
     *
17
     * @param NameNode        $name
18
     * @param DirectiveNode[] $directives
19
     * @param NamedTypeNode[] $types
20
     * @param Location|null   $location
21
     */
22
    public function __construct(NameNode $name, array $directives, array $types, ?Location $location)
23
    {
24
        parent::__construct(NodeKindEnum::UNION_TYPE_EXTENSION, $location);
25
26
        $this->name       = $name;
27
        $this->directives = $directives;
28
        $this->types      = $types;
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function toAST(): array
35
    {
36
        return [
37
            'kind'       => $this->kind,
38
            'name'       => $this->getNameAST(),
39
            'directives' => $this->getDirectivesAST(),
40
            'types'      => $this->getTypesAST(),
41
            'loc'        => $this->getLocationAST(),
42
        ];
43
    }
44
}
45