| Total Complexity | 2 | 
| Total Lines | 23 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 0 | ||
| 1 | <?php | ||
| 22 | trait UpdateMethod | ||
| 23 | { | ||
| 24 | /** | ||
| 25 | * Generic 'updateMethod' method for REST resources. | ||
| 26 | * | ||
| 27 | * @param array<int, string>|null $allowedHttpMethods | ||
| 28 | * | ||
| 29 | * @throws Throwable | ||
| 30 | */ | ||
| 31 | 18 | public function updateMethod( | |
| 32 | Request $request, | ||
| 33 | RestDtoInterface $restDto, | ||
| 34 | string $id, | ||
| 35 | ?array $allowedHttpMethods = null, | ||
| 36 |     ): Response { | ||
|  | |||
| 37 | 18 | $resource = $this->getResourceForMethod($request, $allowedHttpMethods ?? ['PUT']); | |
| 38 | |||
| 39 |         try { | ||
| 40 | 3 | $data = $resource->update($id, $restDto, true); | |
| 41 | |||
| 42 | 2 | return $this->getResponseHandler()->createResponse($request, $data, $resource); | |
| 43 | 1 |         } catch (Throwable $exception) { | |
| 44 | 1 | throw $this->handleRestMethodException($exception, $id); | |
| 45 | } | ||
| 48 |