Passed
Push — 1.0 ( 7bc273...e682a4 )
by Pol
06:25 queued 01:30
created

Logout   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 19
ccs 4
cts 5
cp 0.8
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
    /**
17
     * @param \EcPhp\CasLib\CasInterface $cas
18
     * @param \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokenStorage
19 1
     *
20
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
21
     */
22
    public function __invoke(
23 1
        CasInterface $cas,
24 1
        TokenStorageInterface $tokenStorage
25
    ) {
26 1
        if (null !== $response = $cas->logout()) {
27
            $tokenStorage->setToken();
28
29
            return new RedirectResponse($response->getHeaderLine('location'));
30
        }
31
32
        return new RedirectResponse('/');
33
    }
34
}
35