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

SchemaDefinitionNode::setOperationTypes()   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 SchemaDefinitionNode extends AbstractNode implements TypeSystemDefinitionNodeInterface
9
{
10
11
    use DirectivesTrait;
12
13
    /**
14
     * @var string
15
     */
16
    protected $kind = NodeKindEnum::SCHEMA_DEFINITION;
17
18
    /**
19
     * @var array|OperationTypeDefinitionNode[]
20
     */
21
    protected $operationTypes;
22
23
    /**
24
     * @return OperationTypeDefinitionNode[]
25
     */
26
    public function getOperationTypes(): array
27
    {
28
        return $this->operationTypes;
29
    }
30
31
    /**
32
     * @return array
33
     */
34
    public function getOperationTypesAsArray(): array
35
    {
36
        return array_map(function (SerializationInterface $node) {
37
            return $node->toArray();
38
        }, $this->operationTypes);
39
    }
40
41
    /**
42
     * @param array|OperationTypeDefinitionNode[] $operationTypes
43
     * @return $this
44
     */
45
    public function setOperationTypes(array $operationTypes)
46
    {
47
        $this->operationTypes = $operationTypes;
48
        return $this;
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function toArray(): array
55
    {
56
        return [
57
            'kind'           => $this->kind,
58
            'directives'     => $this->getDirectivesAsArray(),
59
            'operationTypes' => $this->getOperationTypesAsArray(),
60
            'loc'            => $this->getLocationAsArray(),
61
        ];
62
    }
63
}
64