Completed
Push — master ( be5baf...1af7e4 )
by Julito
11:10
created

AuthenticationEntryPoint   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
dl 0
loc 16
rs 10
c 1
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 0 5 1
A __construct() 0 4 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CoreBundle\Security;
6
7
use Symfony\Component\HttpFoundation\RedirectResponse;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Session\SessionInterface;
10
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
11
use Symfony\Component\Security\Core\Exception\AuthenticationException;
12
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
13
14
class AuthenticationEntryPoint implements AuthenticationEntryPointInterface
15
{
16
    private $urlGenerator;
17
    private $session;
18
19
    public function __construct(UrlGeneratorInterface $urlGenerator, SessionInterface $session)
20
    {
21
        $this->urlGenerator = $urlGenerator;
22
        $this->session = $session;
23
    }
24
25
    public function start(Request $request, AuthenticationException $authException = null): RedirectResponse
26
    {
27
        $this->session->getFlashBag()->add('warning', $authException->getMessage());
0 ignored issues
show
Bug introduced by
The method getMessage() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        $this->session->getFlashBag()->add('warning', $authException->/** @scrutinizer ignore-call */ getMessage());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
29
        return new RedirectResponse($this->urlGenerator->generate('login'));
30
    }
31
}
32