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

ArgumentNode   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A toAST() 0 7 1
1
<?php
2
3
namespace Digia\GraphQL\Language\Node;
4
5
use Digia\GraphQL\Language\Location;
6
7
class ArgumentNode extends AbstractNode implements NameAwareInterface
8
{
9
    use NameTrait;
10
    use ValueLiteralTrait;
11
12
    /**
13
     * ArgumentNode constructor.
14
     *
15
     * @param NameNode           $name
16
     * @param ValueNodeInterface $value
17
     * @param Location|null      $location
18
     */
19
    public function __construct(NameNode $name, ValueNodeInterface $value, ?Location $location)
20
    {
21
        parent::__construct(NodeKindEnum::ARGUMENT, $location);
22
23
        $this->name  = $name;
24
        $this->value = $value;
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function toAST(): array
31
    {
32
        return [
33
            'kind'  => $this->kind,
34
            'name'  => $this->getNameAST(),
35
            'value' => $this->getValueAST(),
36
            'loc'   => $this->getLocationAST(),
37
        ];
38
    }
39
}
40