Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Lines | 17 |
Ratio | 100 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
28 | public function onKernelException(GetResponseForExceptionEvent $event) |
||
29 | { |
||
30 | // var_dump does not work here... use |
||
31 | // \Doctrine\Common\Util\Debug::dump($e);die; |
||
32 | if (($exception = $event->getException()) instanceof DeserializationException) { |
||
33 | // hnmm.. no way to find out which property (name) failed?? |
||
34 | $msg = array('message' => $exception->getPrevious()->getMessage()); |
||
35 | |||
36 | $response = $exception->getResponse(); |
||
37 | $response->setStatusCode(Response::HTTP_BAD_REQUEST); |
||
38 | $response->setContent( |
||
39 | $this->getSerializedContent($msg) |
||
40 | ); |
||
41 | |||
42 | $event->setResponse($response); |
||
43 | } |
||
44 | } |
||
45 | } |
||
46 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.