SkautisExceptionListener   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 0
cbo 2
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsException() 0 4 1
A onKernelException() 0 10 2
1
<?php
2
3
namespace SkautisBundle\EventListener;
4
5
use Symfony\Component\HttpFoundation\RedirectResponse;
6
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
7
8
/**
9
 * Listener pro zpracovani neosetrenych \Skautis\Exception
10
 */
11
class SkautisExceptionListener
12
{
13
    /**
14
     * Kontrola zda tento listener obsluhuje dany typ exceptionu
15
     */
16
    protected function supportsException(\Exception $exception)
17
    {
18
        return $exception instanceof \Skautis\Exception;
19
    }
20
21
    /**
22
     * Obsluha vyjimky
23
     */
24
    public function onKernelException(GetResponseForExceptionEvent $event)
25
    {
26
        $exception = $event->getException();
27
        if (!$this->supportsException($exception)) {
28
            return;
29
        }
30
31
        $response = new RedirectResponse("skautis/error");
32
        $event->setResponse($response);
33
    }
34
35
}