Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
24 | 5 | public function onKernelException(ExceptionEvent $event): void |
|
25 | { |
||
26 | 5 | $exception = $event->getThrowable(); |
|
27 | |||
28 | 5 | if ($exception instanceof RequestDtoValidationException) { |
|
29 | 3 | $contentType = 'json'; |
|
30 | 3 | $responseObject = $this->serializer->serialize($exception, $contentType); |
|
31 | 3 | $event->setResponse( |
|
32 | 3 | new JsonResponse( |
|
33 | 3 | $responseObject, |
|
34 | 3 | $exception->getStatusCode(), |
|
35 | 3 | [...$exception->getHeaders(), 'Content-Type' => 'application/problem+json'], |
|
36 | 3 | true |
|
37 | ) |
||
42 |