1
|
|
|
<?php |
2
|
|
|
namespace Arthem\GraphQLMapper\Mapping; |
3
|
|
|
|
4
|
|
|
class SchemaContainer |
5
|
|
|
{ |
6
|
|
|
/** |
7
|
|
|
* @var Type[] |
8
|
|
|
*/ |
9
|
|
|
private $types = []; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @var InterfaceType[] |
13
|
|
|
*/ |
14
|
|
|
private $interfaces = []; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var Query |
18
|
|
|
*/ |
19
|
|
|
private $querySchema; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var Mutation |
23
|
|
|
*/ |
24
|
|
|
private $mutationSchema; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param Type $type |
28
|
|
|
* @return $this |
29
|
|
|
*/ |
30
|
|
|
public function addType(Type $type) |
31
|
|
|
{ |
32
|
|
|
$this->types[$type->getName()] = $type; |
33
|
|
|
|
34
|
|
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param InterfaceType $type |
39
|
|
|
* @return $this |
40
|
|
|
*/ |
41
|
|
|
public function addInterface(InterfaceType $type) |
42
|
|
|
{ |
43
|
|
|
$this->interfaces[$type->getName()] = $type; |
44
|
|
|
|
45
|
|
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return Type[] |
50
|
|
|
*/ |
51
|
|
|
public function getTypes() |
52
|
|
|
{ |
53
|
|
|
return $this->types; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $name |
58
|
|
|
* @return Type |
59
|
|
|
*/ |
60
|
|
|
public function getType($name) |
61
|
|
|
{ |
62
|
|
|
return $this->types[$name]; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param string $name |
67
|
|
|
* @return InterfaceType |
68
|
|
|
*/ |
69
|
|
|
public function getInterface($name) |
70
|
|
|
{ |
71
|
|
|
return $this->interfaces[$name]; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param string $name |
76
|
|
|
* @return bool |
77
|
|
|
*/ |
78
|
|
|
public function hasType($name) |
79
|
|
|
{ |
80
|
|
|
return isset($this->types[$name]); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $name |
85
|
|
|
* @return bool |
86
|
|
|
*/ |
87
|
|
|
public function hasInterface($name) |
88
|
|
|
{ |
89
|
|
|
return isset($this->interfaces[$name]); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return InterfaceType[] |
94
|
|
|
*/ |
95
|
|
|
public function getInterfaces() |
96
|
|
|
{ |
97
|
|
|
return $this->interfaces; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return Query |
102
|
|
|
*/ |
103
|
|
|
public function getQuerySchema() |
104
|
|
|
{ |
105
|
|
|
return $this->querySchema; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param Query $querySchema |
110
|
|
|
* @return $this |
111
|
|
|
*/ |
112
|
|
|
public function setQuerySchema(Query $querySchema) |
113
|
|
|
{ |
114
|
|
|
$this->querySchema = $querySchema; |
115
|
|
|
|
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return Mutation |
121
|
|
|
*/ |
122
|
|
|
public function getMutationSchema() |
123
|
|
|
{ |
124
|
|
|
return $this->mutationSchema; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param Mutation $mutationSchema |
129
|
|
|
* @return $this |
130
|
|
|
*/ |
131
|
|
|
public function setMutationSchema(Mutation $mutationSchema) |
132
|
|
|
{ |
133
|
|
|
$this->mutationSchema = $mutationSchema; |
134
|
|
|
|
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|