Passed
Pull Request — master (#23)
by Christoffer
02:07 queued 19s
created

ObjectValueNode::setFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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