1 | <?php |
||
21 | final class ResourceMetadata |
||
22 | { |
||
23 | private $shortName; |
||
24 | private $description; |
||
25 | private $iri; |
||
26 | private $itemOperations; |
||
27 | private $collectionOperations; |
||
28 | private $graphql; |
||
29 | private $attributes; |
||
30 | |||
31 | public function __construct(string $shortName = null, string $description = null, string $iri = null, array $itemOperations = null, array $collectionOperations = null, array $attributes = null, array $graphql = null) |
||
32 | { |
||
33 | $this->shortName = $shortName; |
||
34 | $this->description = $description; |
||
35 | $this->iri = $iri; |
||
36 | $this->itemOperations = $itemOperations; |
||
37 | $this->collectionOperations = $collectionOperations; |
||
38 | $this->graphql = $graphql; |
||
39 | $this->attributes = $attributes; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Gets the short name. |
||
44 | * |
||
45 | * @return string|null |
||
46 | */ |
||
47 | public function getShortName() |
||
48 | { |
||
49 | return $this->shortName; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Returns a new instance with the given short name. |
||
54 | * |
||
55 | * @param string $shortName |
||
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 a collection operation attribute, optionally fallback to a resource attribute. |
||
151 | * |
||
152 | * @param string|null $operationName |
||
153 | * @param mixed $defaultValue |
||
154 | * |
||
155 | * @return mixed |
||
156 | */ |
||
157 | public function getCollectionOperationAttribute(string $operationName = null, string $key, $defaultValue = null, bool $resourceFallback = false) |
||
161 | |||
162 | /** |
||
163 | * Gets an item operation attribute, optionally fallback to a resource attribute. |
||
164 | * |
||
165 | * @param string|null $operationName |
||
166 | * @param mixed $defaultValue |
||
167 | * |
||
168 | * @return mixed |
||
169 | */ |
||
170 | public function getItemOperationAttribute(string $operationName = null, string $key, $defaultValue = null, bool $resourceFallback = false) |
||
174 | |||
175 | /** |
||
176 | * Gets an operation attribute, optionally fallback to a resource attribute. |
||
177 | * |
||
178 | * @param array|null $operations |
||
179 | * @param string|null $operationName |
||
180 | * @param mixed $defaultValue |
||
181 | * |
||
182 | * @return mixed |
||
183 | */ |
||
184 | private function getOperationAttribute(array $operations = null, string $operationName = null, string $key, $defaultValue = null, bool $resourceFallback = false) |
||
196 | |||
197 | /** |
||
198 | * @return mixed |
||
199 | */ |
||
200 | public function getGraphqlAttribute(string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false) |
||
212 | |||
213 | /** |
||
214 | * Gets attributes. |
||
215 | * |
||
216 | * @return array|null |
||
217 | */ |
||
218 | public function getAttributes() |
||
222 | |||
223 | /** |
||
224 | * Gets an attribute. |
||
225 | * |
||
226 | * @param mixed $defaultValue |
||
227 | * |
||
228 | * @return mixed |
||
229 | */ |
||
230 | public function getAttribute(string $key, $defaultValue = null) |
||
238 | |||
239 | /** |
||
240 | * Returns a new instance with the given attribute. |
||
241 | */ |
||
242 | public function withAttributes(array $attributes): self |
||
249 | |||
250 | /** |
||
251 | * Gets options of for the GraphQL query. |
||
252 | * |
||
253 | * @return array|null |
||
254 | */ |
||
255 | public function getGraphql() |
||
259 | |||
260 | /** |
||
261 | * Returns a new instance with the given GraphQL options. |
||
262 | */ |
||
263 | public function withGraphql(array $graphql): self |
||
270 | } |
||
271 |