AjaxAuthenticationListener   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A onCoreException() 0 11 4
1
<?php
2
3
namespace Vivait\BootstrapBundle\EventListener;
4
5
use Symfony\Component\HttpFoundation\Response;
6
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
7
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
8
use Symfony\Component\Security\Core\Exception\AuthenticationException;
9
10
class AjaxAuthenticationListener
11
{
12
13
    /**
14
     * Handles security related exceptions.
15
     *
16
     * @param GetResponseForExceptionEvent $event An GetResponseForExceptionEvent instance
17
     */
18
    public function onCoreException(GetResponseForExceptionEvent $event)
19
    {
20
        $exception = $event->getException();
21
        $request = $event->getRequest();
22
23
        if ($request->isXmlHttpRequest()) {
24
            if ($exception instanceof AuthenticationException || $exception instanceof AccessDeniedException) {
0 ignored issues
show
Bug introduced by
The class Symfony\Component\Securi...AuthenticationException does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
Bug introduced by
The class Symfony\Component\Securi...n\AccessDeniedException does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
25
                $event->setResponse(new Response('', 403));
26
            }
27
        }
28
    }
29
}