Passed
Push — master ( da4ce9...54c779 )
by Christoffer
02:24
created

ExtendInfo::getSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Digia\GraphQL\Schema\Extension;
4
5
use Digia\GraphQL\Language\Node\DirectiveDefinitionNode;
6
use Digia\GraphQL\Language\Node\DocumentNode;
7
use Digia\GraphQL\Language\Node\InterfaceTypeExtensionNode;
8
use Digia\GraphQL\Language\Node\ObjectTypeExtensionNode;
9
use Digia\GraphQL\Language\Node\SchemaExtensionNode;
10
use Digia\GraphQL\Language\Node\TypeSystemDefinitionNodeInterface;
11
use Digia\GraphQL\Schema\Schema;
12
13
class ExtendInfo
14
{
15
    /**
16
     * @var Schema
17
     */
18
    protected $schema;
19
20
    /**
21
     * @var DocumentNode
22
     */
23
    protected $document;
24
25
    /**
26
     * @var TypeSystemDefinitionNodeInterface[]
27
     */
28
    protected $typeDefinitionMap;
29
30
    /**
31
     * @var InterfaceTypeExtensionNode[][]|ObjectTypeExtensionNode[][]
32
     */
33
    protected $typeExtensionsMap;
34
35
    /**
36
     * @var DirectiveDefinitionNode[]
37
     */
38
    protected $directiveDefinitions;
39
40
    /**
41
     * @var SchemaExtensionNode[]
42
     */
43
    protected $schemaExtensions;
44
45
    /**
46
     * ExtensionInfo constructor.
47
     * @param Schema                                                     $schema
48
     * @param DocumentNode                                               $document
49
     * @param TypeSystemDefinitionNodeInterface[]                        $typeDefinitionMap
50
     * @param InterfaceTypeExtensionNode[][]|ObjectTypeExtensionNode[][] $typeExtensionsMap
51
     * @param DirectiveDefinitionNode[]                                  $directiveDefinitions
52
     * @param SchemaExtensionNode[]                                      $schemaExtensions
53
     */
54
    public function __construct(
55
        Schema $schema,
56
        DocumentNode $document,
57
        array $typeDefinitionMap,
58
        array $typeExtensionsMap,
59
        array $directiveDefinitions,
60
        array $schemaExtensions
61
    ) {
62
        $this->schema               = $schema;
63
        $this->document             = $document;
64
        $this->typeDefinitionMap    = $typeDefinitionMap;
65
        $this->typeExtensionsMap    = $typeExtensionsMap;
66
        $this->directiveDefinitions = $directiveDefinitions;
67
        $this->schemaExtensions     = $schemaExtensions;
68
    }
69
70
    /**
71
     * @param string $typeName
72
     * @return bool
73
     */
74
    public function hasTypeExtensions(string $typeName): bool
75
    {
76
        return isset($this->typeExtensionsMap[$typeName]);
77
    }
78
79
    /**
80
     * @param string $typeName
81
     * @return ObjectTypeExtensionNode[]|InterfaceTypeExtensionNode[]
82
     */
83
    public function getTypeExtensions(string $typeName): array
84
    {
85
        return $this->typeExtensionsMap[$typeName] ?? [];
86
    }
87
88
    /**
89
     * @return Schema
90
     */
91
    public function getSchema(): Schema
92
    {
93
        return $this->schema;
94
    }
95
96
    /**
97
     * @return DocumentNode
98
     */
99
    public function getDocument(): DocumentNode
100
    {
101
        return $this->document;
102
    }
103
104
    /**
105
     * @return bool
106
     */
107
    public function hasTypeDefinitionMap(): bool
108
    {
109
        return !empty($this->typeDefinitionMap);
110
    }
111
112
    /**
113
     * @return TypeSystemDefinitionNodeInterface[]
114
     */
115
    public function getTypeDefinitionMap(): array
116
    {
117
        return $this->typeDefinitionMap;
118
    }
119
120
    /**
121
     * @return bool
122
     */
123
    public function hasTypeExtensionsMap(): bool
124
    {
125
        return !empty($this->typeExtensionsMap);
126
    }
127
128
    /**
129
     * @return InterfaceTypeExtensionNode[][]|ObjectTypeExtensionNode[][]
130
     */
131
    public function getTypeExtensionsMap()
132
    {
133
        return $this->typeExtensionsMap;
134
    }
135
136
    /**
137
     * @return bool
138
     */
139
    public function hasDirectiveDefinitions(): bool
140
    {
141
        return !empty($this->directiveDefinitions);
142
    }
143
144
    /**
145
     * @return DirectiveDefinitionNode[]
146
     */
147
    public function getDirectiveDefinitions(): array
148
    {
149
        return $this->directiveDefinitions;
150
    }
151
152
    /**
153
     * @return bool
154
     */
155
    public function hasSchemaExtensions(): bool
156
    {
157
        return !empty($this->schemaExtensions);
158
    }
159
160
    /**
161
     * @return SchemaExtensionNode[]
162
     */
163
    public function getSchemaExtensions(): array
164
    {
165
        return $this->schemaExtensions;
166
    }
167
}
168