1 | <?php |
||
21 | final class ResourceMetadata |
||
22 | { |
||
23 | private $shortName; |
||
24 | private $description; |
||
25 | private $iri; |
||
26 | private $itemOperations; |
||
27 | private $collectionOperations; |
||
28 | private $subresourceOperations; |
||
29 | private $graphql; |
||
30 | private $attributes; |
||
31 | |||
32 | public function __construct(string $shortName = null, string $description = null, string $iri = null, array $itemOperations = null, array $collectionOperations = null, array $attributes = null, array $subresourceOperations = null, array $graphql = null) |
||
33 | { |
||
34 | $this->shortName = $shortName; |
||
35 | $this->description = $description; |
||
36 | $this->iri = $iri; |
||
37 | $this->itemOperations = $itemOperations; |
||
38 | $this->collectionOperations = $collectionOperations; |
||
39 | $this->subresourceOperations = $subresourceOperations; |
||
40 | $this->graphql = $graphql; |
||
41 | $this->attributes = $attributes; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Gets the short name. |
||
46 | * |
||
47 | * @return string|null |
||
48 | */ |
||
49 | public function getShortName() |
||
50 | { |
||
51 | return $this->shortName; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Returns a new instance with the given short name. |
||
56 | */ |
||
57 | public function withShortName(string $shortName): self |
||
64 | |||
65 | /** |
||
66 | * Gets the description. |
||
67 | * |
||
68 | * @return string|null |
||
69 | */ |
||
70 | public function getDescription() |
||
74 | |||
75 | /** |
||
76 | * Returns a new instance with the given description. |
||
77 | */ |
||
78 | public function withDescription(string $description): self |
||
85 | |||
86 | /** |
||
87 | * Gets the associated IRI. |
||
88 | * |
||
89 | * @return string|null |
||
90 | */ |
||
91 | public function getIri() |
||
95 | |||
96 | /** |
||
97 | * Returns a new instance with the given IRI. |
||
98 | */ |
||
99 | public function withIri(string $iri): self |
||
106 | |||
107 | /** |
||
108 | * Gets item operations. |
||
109 | * |
||
110 | * @return array|null |
||
111 | */ |
||
112 | public function getItemOperations() |
||
116 | |||
117 | /** |
||
118 | * Returns a new instance with the given item operations. |
||
119 | */ |
||
120 | public function withItemOperations(array $itemOperations): self |
||
127 | |||
128 | /** |
||
129 | * Gets collection operations. |
||
130 | * |
||
131 | * @return array|null |
||
132 | */ |
||
133 | public function getCollectionOperations() |
||
137 | |||
138 | /** |
||
139 | * Returns a new instance with the given collection operations. |
||
140 | */ |
||
141 | public function withCollectionOperations(array $collectionOperations): self |
||
148 | |||
149 | /** |
||
150 | * Gets subresource operations. |
||
151 | * |
||
152 | * @return array|null |
||
153 | */ |
||
154 | public function getSubresourceOperations() |
||
158 | |||
159 | /** |
||
160 | * Returns a new instance with the given subresource operations. |
||
161 | */ |
||
162 | public function withSubresourceOperations(array $subresourceOperations): self |
||
169 | |||
170 | /** |
||
171 | * Gets a collection operation attribute, optionally fallback to a resource attribute. |
||
172 | * |
||
173 | * @param mixed $defaultValue |
||
174 | * |
||
175 | * @return mixed |
||
176 | */ |
||
177 | public function getCollectionOperationAttribute(string $operationName = null, string $key, $defaultValue = null, bool $resourceFallback = false) |
||
181 | |||
182 | /** |
||
183 | * Gets an item operation attribute, optionally fallback to a resource attribute. |
||
184 | * |
||
185 | * @param mixed $defaultValue |
||
186 | * |
||
187 | * @return mixed |
||
188 | */ |
||
189 | public function getItemOperationAttribute(string $operationName = null, string $key, $defaultValue = null, bool $resourceFallback = false) |
||
193 | |||
194 | /** |
||
195 | * Gets a subresource operation attribute, optionally fallback to a resource attribute. |
||
196 | * |
||
197 | * @param mixed $defaultValue |
||
198 | * |
||
199 | * @return mixed |
||
200 | */ |
||
201 | public function getSubresourceOperationAttribute(string $operationName = null, string $key, $defaultValue = null, bool $resourceFallback = false) |
||
205 | |||
206 | /** |
||
207 | * Gets an operation attribute, optionally fallback to a resource attribute. |
||
208 | * |
||
209 | * @param mixed $defaultValue |
||
210 | * |
||
211 | * @return mixed |
||
212 | */ |
||
213 | private function getOperationAttribute(array $operations = null, string $operationName = null, string $key, $defaultValue = null, bool $resourceFallback = false) |
||
225 | |||
226 | /** |
||
227 | * @return mixed |
||
228 | */ |
||
229 | public function getGraphqlAttribute(string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false) |
||
241 | |||
242 | /** |
||
243 | * Gets attributes. |
||
244 | * |
||
245 | * @return array|null |
||
246 | */ |
||
247 | public function getAttributes() |
||
251 | |||
252 | /** |
||
253 | * Gets an attribute. |
||
254 | * |
||
255 | * @param mixed $defaultValue |
||
256 | * |
||
257 | * @return mixed |
||
258 | */ |
||
259 | public function getAttribute(string $key, $defaultValue = null) |
||
267 | |||
268 | /** |
||
269 | * Returns a new instance with the given attribute. |
||
270 | */ |
||
271 | public function withAttributes(array $attributes): self |
||
278 | |||
279 | /** |
||
280 | * Gets options of for the GraphQL query. |
||
281 | * |
||
282 | * @return array|null |
||
283 | */ |
||
284 | public function getGraphql() |
||
288 | |||
289 | /** |
||
290 | * Returns a new instance with the given GraphQL options. |
||
291 | */ |
||
292 | public function withGraphql(array $graphql): self |
||
299 | } |
||
300 |