LogoutSuccessHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onLogoutSuccess() 0 9 2
A __construct() 0 4 1
1
<?php
2
3
namespace App\Security;
4
5
use Symfony\Component\HttpFoundation\RedirectResponse;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Routing\RouterInterface;
9
use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface;
10
11
class LogoutSuccessHandler implements LogoutSuccessHandlerInterface
12
{
13
    private $router;
14
    private $shibUaid;
15
16
    public function __construct(RouterInterface $router, $shibUaid)
17
    {
18
        $this->router = $router;
19
        $this->shibUaid = $shibUaid;
20
    }
21
22
    /**
23
     * Creates a Response object to send upon a successful logout.
24
     *
25
     * @param Request $request
26
     * @return Response never null
27
     */
28
    public function onLogoutSuccess(Request $request)
29
    {
30
        if ($request->server->has($this->shibUaid)) {
31
            return new RedirectResponse($this->router->generate('shib_logout',
32
                array(
33
                    'return' => $this->router->generate('login')
34
                )));
35
        } else {
36
            return new RedirectResponse($this->router->generate('login'));
37
        }
38
    }
39
}
40