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

ObjectValueNode   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFields() 0 3 1
A setFields() 0 4 1
A getFieldsAsArray() 0 5 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 ObjectValueNode extends AbstractNode implements ValueNodeInterface
9
{
10
11
    /**
12
     * @var string
13
     */
14
    protected $kind = NodeKindEnum::OBJECT;
15
16
    /**
17
     * @var ObjectFieldNode[]
18
     */
19
    protected $fields;
20
21
    /**
22
     * @return ObjectFieldNode[]
23
     */
24
    public function getFields(): array
25
    {
26
        return $this->fields;
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function getFieldsAsArray(): array
33
    {
34
        return array_map(function (SerializationInterface $node) {
35
            return $node->toArray();
36
        }, $this->fields);
37
    }
38
39
    /**
40
     * @param array $fields
41
     * @return $this
42
     */
43
    public function setFields(array $fields)
44
    {
45
        $this->fields = $fields;
46
        return $this;
47
    }
48
}
49