Completed
Push — master ( 7faae5...9f7b4d )
by Christoffer
02:27
created

SchemaDefinitionNode::getOperationTypesAsArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Language\AST\Node;
4
5
use Digia\GraphQL\Contract\SerializationInterface;
6
use Digia\GraphQL\Language\AST\Node\Behavior\DirectivesTrait;
7
use Digia\GraphQL\Language\AST\Node\Contract\TypeSystemDefinitionNodeInterface;
8
use Digia\GraphQL\Language\AST\NodeKindEnum;
9
10
class SchemaDefinitionNode extends AbstractNode implements TypeSystemDefinitionNodeInterface
11
{
12
13
    use DirectivesTrait;
14
15
    /**
16
     * @var string
17
     */
18
    protected $kind = NodeKindEnum::SCHEMA_DEFINITION;
19
20
    /**
21
     * @var OperationTypeDefinitionNode[]
22
     */
23
    protected $operationTypes;
24
25
    /**
26
     * @return OperationTypeDefinitionNode[]
27
     */
28
    public function getOperationTypes(): array
29
    {
30
        return $this->operationTypes;
31
    }
32
33
    public function getOperationTypesAsArray(): array
34
    {
35
        return array_map(function (SerializationInterface $node) {
36
            return $node->toArray();
37
        }, $this->operationTypes);
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function toArray(): array
44
    {
45
        return [
46
            'kind'           => $this->kind,
47
            'directives'     => $this->getDirectivesAsArray(),
48
            'operationTypes' => $this->getOperationTypesAsArray(),
49
            'loc'            => $this->getLocationAsArray(),
50
        ];
51
    }
52
}
53