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

Logout::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 11
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
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