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

FieldDefinitionNode::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Digia\GraphQL\Language\Node;
4
5
use Digia\GraphQL\Language\Location;
6
7
class FieldDefinitionNode extends AbstractNode implements DefinitionNodeInterface, DirectivesAwareInterface,
8
    NameAwareInterface
9
{
10
    use TypeTrait;
11
    use NameTrait;
12
    use DescriptionTrait;
13
    use InputArgumentsTrait;
14
    use DirectivesTrait;
15
16
    /**
17
     * FieldDefinitionNode constructor.
18
     *
19
     * @param StringValueNode|null       $description
20
     * @param NameNode                   $name
21
     * @param InputValueDefinitionNode[] $arguments
22
     * @param TypeNodeInterface          $type
23
     * @param DirectiveNode[]            $directives
24
     * @param Location|null              $location
25
     */
26
    public function __construct(
27
        ?StringValueNode $description,
28
        NameNode $name,
29
        array $arguments,
30
        TypeNodeInterface $type,
31
        array $directives,
32
        ?Location $location
33
    ) {
34
        parent::__construct(NodeKindEnum::FIELD_DEFINITION, $location);
35
36
        $this->description = $description;
37
        $this->name        = $name;
38
        $this->arguments   = $arguments;
39
        $this->type        = $type;
40
        $this->directives  = $directives;
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46
    public function toAST(): array
47
    {
48
        return [
49
            'kind'        => $this->kind,
50
            'description' => $this->description,
51
            'name'        => $this->getNameAST(),
52
            'arguments'   => $this->getArgumentsAST(),
53
            'type'        => $this->getTypeAST(),
54
            'directives'  => $this->getDirectivesAST(),
55
            'loc'         => $this->getLocationAST(),
56
        ];
57
    }
58
}
59