Passed
Push — 1.0 ( 07d681...376964 )
by Pol
03:57
created

Logout   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 13
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

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