1 | <?php |
||
22 | abstract class ResourceEndpoint implements Endpoint |
||
23 | { |
||
24 | /** |
||
25 | * @var ResourceParametersFactory |
||
26 | */ |
||
27 | protected $resourceParametersFactory; |
||
28 | /** |
||
29 | * @var ResourceAPIResponseDataFactory |
||
30 | */ |
||
31 | protected $resourceAPIResponseDataFactory; |
||
32 | |||
33 | /** |
||
34 | * ResourceEndpoint constructor. |
||
35 | * @param ResourceParametersFactory $parametersFactory |
||
36 | * @param ResourceAPIResponseDataFactory $APIResponseDataFactory |
||
37 | */ |
||
38 | 80 | public function __construct( |
|
46 | |||
47 | /** |
||
48 | * @param APIRequest $request |
||
49 | * @return APIResponseData |
||
50 | * @throws EndpointExecutionException |
||
51 | * @throws UnsupportedMethodException |
||
52 | * @throws ElementNotFoundException |
||
53 | * @throws InvalidRequestException |
||
54 | * @throws UnableToCreateAPIResponseDataException |
||
55 | * @throws UnableToCreateResourceParametersException |
||
56 | */ |
||
57 | 6 | public function get(APIRequest $request): APIResponseData |
|
65 | |||
66 | /** |
||
67 | * @param APIRequest $request |
||
68 | * @return APIResponseData |
||
69 | * @throws EndpointExecutionException |
||
70 | * @throws UnsupportedMethodException |
||
71 | * @throws InvalidRequestException |
||
72 | * @throws UnableToCreateAPIResponseDataException |
||
73 | * @throws UnableToCreateResourceParametersException |
||
74 | */ |
||
75 | 6 | public function getAll(APIRequest $request): APIResponseData |
|
83 | |||
84 | /** |
||
85 | * @param APIRequest $request |
||
86 | * @return APIResponseData |
||
87 | * @throws EndpointExecutionException |
||
88 | * @throws UnsupportedMethodException |
||
89 | * @throws ElementNotFoundException |
||
90 | * @throws ElementConflictException |
||
91 | * @throws InvalidRequestException |
||
92 | * @throws UnableToCreateAPIResponseDataException |
||
93 | * @throws UnableToCreateResourceParametersException |
||
94 | */ |
||
95 | 7 | public function post(APIRequest $request): APIResponseData |
|
103 | |||
104 | /** |
||
105 | * @param APIRequest $request |
||
106 | * @return APIResponseData |
||
107 | * @throws EndpointExecutionException |
||
108 | * @throws UnsupportedMethodException |
||
109 | * @throws InvalidRequestException |
||
110 | * @throws ElementConflictException |
||
111 | * @throws UnableToCreateAPIResponseDataException |
||
112 | * @throws UnableToCreateResourceParametersException |
||
113 | */ |
||
114 | 7 | public function postAll(APIRequest $request): APIResponseData |
|
122 | |||
123 | /** |
||
124 | * @param APIRequest $request |
||
125 | * @return APIResponseData |
||
126 | * @throws EndpointExecutionException |
||
127 | * @throws UnsupportedMethodException |
||
128 | * @throws ElementNotFoundException |
||
129 | * @throws InvalidRequestException |
||
130 | * @throws ElementConflictException |
||
131 | * @throws UnableToCreateAPIResponseDataException |
||
132 | * @throws UnableToCreateResourceParametersException |
||
133 | */ |
||
134 | 7 | public function put(APIRequest $request): APIResponseData |
|
142 | |||
143 | /** |
||
144 | * @param APIRequest $request |
||
145 | * @return APIResponseData |
||
146 | * @throws EndpointExecutionException |
||
147 | * @throws UnsupportedMethodException |
||
148 | * @throws InvalidRequestException |
||
149 | * @throws ElementConflictException |
||
150 | * @throws UnableToCreateAPIResponseDataException |
||
151 | * @throws UnableToCreateResourceParametersException |
||
152 | */ |
||
153 | 7 | public function putAll(APIRequest $request): APIResponseData |
|
161 | |||
162 | /** |
||
163 | * @param APIRequest $request |
||
164 | * @return APIResponseData |
||
165 | * @throws EndpointExecutionException |
||
166 | * @throws UnsupportedMethodException |
||
167 | * @throws ElementNotFoundException |
||
168 | * @throws InvalidRequestException |
||
169 | * @throws ElementConflictException |
||
170 | * @throws UnableToCreateAPIResponseDataException |
||
171 | * @throws UnableToCreateResourceParametersException |
||
172 | */ |
||
173 | 7 | public function patch(APIRequest $request): APIResponseData |
|
181 | |||
182 | /** |
||
183 | * @param APIRequest $request |
||
184 | * @return APIResponseData |
||
185 | * @throws EndpointExecutionException |
||
186 | * @throws UnsupportedMethodException |
||
187 | * @throws InvalidRequestException |
||
188 | * @throws ElementConflictException |
||
189 | * @throws UnableToCreateAPIResponseDataException |
||
190 | * @throws UnableToCreateResourceParametersException |
||
191 | */ |
||
192 | 7 | public function patchAll(APIRequest $request): APIResponseData |
|
200 | |||
201 | /** |
||
202 | * @param APIRequest $request |
||
203 | * @return APIResponseData |
||
204 | * @throws EndpointExecutionException |
||
205 | * @throws UnsupportedMethodException |
||
206 | * @throws ElementNotFoundException |
||
207 | * @throws InvalidRequestException |
||
208 | * @throws UnableToCreateAPIResponseDataException |
||
209 | * @throws UnableToCreateResourceParametersException |
||
210 | */ |
||
211 | 7 | public function options(APIRequest $request): APIResponseData |
|
219 | |||
220 | /** |
||
221 | * @param APIRequest $request |
||
222 | * @return APIResponseData |
||
223 | * @throws EndpointExecutionException |
||
224 | * @throws UnsupportedMethodException |
||
225 | * @throws InvalidRequestException |
||
226 | * @throws UnableToCreateAPIResponseDataException |
||
227 | * @throws UnableToCreateResourceParametersException |
||
228 | */ |
||
229 | 7 | public function optionsAll(APIRequest $request): APIResponseData |
|
237 | |||
238 | /** |
||
239 | * @param APIRequest $request |
||
240 | * @return APIResponseData |
||
241 | * @throws EndpointExecutionException |
||
242 | * @throws UnsupportedMethodException |
||
243 | * @throws ElementNotFoundException |
||
244 | * @throws InvalidRequestException |
||
245 | * @throws UnableToCreateAPIResponseDataException |
||
246 | * @throws UnableToCreateResourceParametersException |
||
247 | */ |
||
248 | 6 | public function delete(APIRequest $request): APIResponseData |
|
256 | |||
257 | /** |
||
258 | * @param APIRequest $request |
||
259 | * @return APIResponseData |
||
260 | * @throws EndpointExecutionException |
||
261 | * @throws UnsupportedMethodException |
||
262 | * @throws InvalidRequestException |
||
263 | * @throws UnableToCreateAPIResponseDataException |
||
264 | * @throws UnableToCreateResourceParametersException |
||
265 | */ |
||
266 | 6 | public function deleteAll(APIRequest $request): APIResponseData |
|
274 | |||
275 | /** |
||
276 | * @param ResourceParameters $parameters |
||
277 | * @return Resource |
||
278 | * @throws EndpointExecutionException |
||
279 | * @throws UnsupportedMethodException |
||
280 | * @throws ElementNotFoundException |
||
281 | * @throws InvalidRequestException |
||
282 | */ |
||
283 | abstract protected function getResource(ResourceParameters $parameters): Resource; |
||
284 | |||
285 | /** |
||
286 | * @param ResourceParameters $parameters |
||
287 | * @return Resource[] |
||
288 | * @throws EndpointExecutionException |
||
289 | * @throws UnsupportedMethodException |
||
290 | * @throws ElementNotFoundException |
||
291 | * @throws InvalidRequestException |
||
292 | */ |
||
293 | abstract protected function getResources(ResourceParameters $parameters): array; |
||
294 | |||
295 | /** |
||
296 | * @param ResourceParameters $parameters |
||
297 | * @return Resource |
||
298 | * @throws EndpointExecutionException |
||
299 | * @throws UnsupportedMethodException |
||
300 | * @throws ElementNotFoundException |
||
301 | * @throws ElementConflictException |
||
302 | * @throws InvalidRequestException |
||
303 | */ |
||
304 | abstract protected function postResource(ResourceParameters $parameters): Resource; |
||
305 | |||
306 | /** |
||
307 | * @param ResourceParameters $parameters |
||
308 | * @return Resource |
||
309 | * @throws EndpointExecutionException |
||
310 | * @throws UnsupportedMethodException |
||
311 | * @throws ElementConflictException |
||
312 | * @throws InvalidRequestException |
||
313 | */ |
||
314 | abstract protected function postResources(ResourceParameters $parameters): Resource; |
||
315 | |||
316 | /** |
||
317 | * @param ResourceParameters $parameters |
||
318 | * @return Resource |
||
319 | * @throws EndpointExecutionException |
||
320 | * @throws UnsupportedMethodException |
||
321 | * @throws ElementNotFoundException |
||
322 | * @throws ElementConflictException |
||
323 | * @throws InvalidRequestException |
||
324 | */ |
||
325 | abstract protected function putResource(ResourceParameters $parameters): Resource; |
||
326 | |||
327 | /** |
||
328 | * @param ResourceParameters[] $parameters |
||
329 | * @return Resource[] |
||
330 | * @throws EndpointExecutionException |
||
331 | * @throws UnsupportedMethodException |
||
332 | * @throws ElementConflictException |
||
333 | * @throws InvalidRequestException |
||
334 | */ |
||
335 | abstract protected function putResources(array $parameters): array; |
||
336 | |||
337 | /** |
||
338 | * @param ResourceParameters $parameters |
||
339 | * @return Resource |
||
340 | * @throws EndpointExecutionException |
||
341 | * @throws UnsupportedMethodException |
||
342 | * @throws ElementNotFoundException |
||
343 | * @throws ElementConflictException |
||
344 | * @throws InvalidRequestException |
||
345 | */ |
||
346 | abstract protected function patchResource(ResourceParameters $parameters): Resource; |
||
347 | |||
348 | /** |
||
349 | * @param ResourceParameters[] $parameters |
||
350 | * @return Resource[] |
||
351 | * @throws EndpointExecutionException |
||
352 | * @throws UnsupportedMethodException |
||
353 | * @throws ElementNotFoundException |
||
354 | * @throws ElementConflictException |
||
355 | * @throws InvalidRequestException |
||
356 | */ |
||
357 | abstract protected function patchResources(array $parameters): array; |
||
358 | |||
359 | /** |
||
360 | * @param ResourceParameters $parameters |
||
361 | * @return Resource |
||
362 | * @throws EndpointExecutionException |
||
363 | * @throws UnsupportedMethodException |
||
364 | * @throws InvalidRequestException |
||
365 | */ |
||
366 | abstract protected function optionsResource(ResourceParameters $parameters): Resource; |
||
367 | |||
368 | /** |
||
369 | * @param ResourceParameters[] $parameters |
||
370 | * @return Resource[] |
||
371 | * @throws EndpointExecutionException |
||
372 | * @throws UnsupportedMethodException |
||
373 | * @throws InvalidRequestException |
||
374 | */ |
||
375 | abstract protected function optionsResources(array $parameters): array; |
||
376 | |||
377 | /** |
||
378 | * @param ResourceParameters $parameters |
||
379 | * @return Resource|null |
||
380 | * @throws EndpointExecutionException |
||
381 | * @throws UnsupportedMethodException |
||
382 | * @throws ElementNotFoundException |
||
383 | * @throws InvalidRequestException |
||
384 | */ |
||
385 | abstract protected function deleteResource(ResourceParameters $parameters): ?Resource; |
||
386 | |||
387 | /** |
||
388 | * @param ResourceParameters $parameters |
||
389 | * @return Resource[]|null |
||
390 | * @throws EndpointExecutionException |
||
391 | * @throws UnsupportedMethodException |
||
392 | * @throws ElementNotFoundException |
||
393 | * @throws InvalidRequestException |
||
394 | */ |
||
395 | abstract protected function deleteResources(ResourceParameters $parameters): ?array; |
||
396 | |||
397 | } |
||
398 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: