Passed
Pull Request — master (#23)
by Christoffer
01:53
created

ListValueNode   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getValuesAsArray() 0 5 1
A getValues() 0 3 1
A toArray() 0 6 1
A setValues() 0 4 1
1
<?php
2
3
namespace Digia\GraphQL\Language\AST\Node;
4
5
use Digia\GraphQL\Language\AST\NodeKindEnum;
6
use Digia\GraphQL\Util\SerializationInterface;
7
8
class ListValueNode extends AbstractNode implements ValueNodeInterface
9
{
10
11
    /**
12
     * @var string
13
     */
14
    protected $kind = NodeKindEnum::LIST;
15
16
    /**
17
     * @var array|ValueNodeInterface[]
18
     */
19
    protected $values;
20
21
    /**
22
     * @return array|ValueNodeInterface[]
23
     */
24
    public function getValues(): array
25
    {
26
        return $this->values;
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function getValuesAsArray(): array
33
    {
34
        return array_map(function (SerializationInterface $node) {
35
            return $node->toArray();
36
        }, $this->values);
37
    }
38
39
    /**
40
     * @param array|ValueNodeInterface[] $values
41
     * @return $this
42
     */
43
    public function setValues(array $values)
44
    {
45
        $this->values = $values;
46
        return $this;
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    public function toArray(): array
53
    {
54
        return [
55
            'kind'   => $this->kind,
56
            'loc'    => $this->getLocationAsArray(),
57
            'values' => $this->getValuesAsArray(),
58
        ];
59
    }
60
}
61