Logout   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 19
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace drupol\CasBundle\Controller;
6
7
use drupol\psrcas\CasInterface;
8
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
9
use Symfony\Component\HttpFoundation\RedirectResponse;
10
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
11
12
/**
13
 * Class Logout.
14
 */
15
final class Logout extends AbstractController
16
{
17
    /**
18
     * @param \drupol\psrcas\CasInterface $cas
19
     * @param \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokenStorage
20
     *
21
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
22
     */
23 1
    public function __invoke(
24
        CasInterface $cas,
25
        TokenStorageInterface $tokenStorage
26
    ) {
27 1
        if (null !== $response = $cas->logout()) {
28 1
            $tokenStorage->setToken();
29
30 1
            return new RedirectResponse($response->getHeaderLine('location'));
31
        }
32
33
        return new RedirectResponse('/');
34
    }
35
}
36