Completed
Pull Request — master (#30)
by nonanerz
05:03
created

ExceptionListener::onKernelException()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.3149

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 11
ccs 4
cts 7
cp 0.5714
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
crap 2.3149
1
<?php
2
3
namespace AppBundle\Exception;
4
5
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
6
7
class ExceptionListener
8
{
9 5
    public function onKernelException(GetResponseForExceptionEvent $event)
10
    {
11 5
        $exception = $event->getException();
12 5
        if (!$exception instanceof \Google_Exception) {
13 5
            return;
14
        }
15
16
        $jsonException = new JsonHttpException($exception->getCode(), $exception->getMessage());
17
18
        $event->setException($jsonException);
19
    }
20
}
21