LogoutFallback::supports()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace AerialShip\SamlSPBundle\Bridge;
4
5
use AerialShip\SamlSPBundle\RelyingParty\RelyingPartyInterface;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\Security\Http\HttpUtils;
8
9
class LogoutFallback implements RelyingPartyInterface
10
{
11
    /** @var \Symfony\Component\Security\Http\HttpUtils  */
12
    protected $httpUtils;
13
14
15
16
    public function __construct(HttpUtils $httpUtils)
17
    {
18
        $this->httpUtils = $httpUtils;
19
    }
20
21
22
23
    /**
24
     * @param \Symfony\Component\HttpFoundation\Request $request
25
     * @return bool
26
     */
27
    public function supports(Request $request)
28
    {
29
        if ($request->attributes->get('logout_path') == $request->getPathInfo()) {
30
            return true;
31
        }
32
        return false;
33
    }
34
35
    /**
36
     * @param \Symfony\Component\HttpFoundation\Request $request
37
     * @throws \InvalidArgumentException if cannot manage the Request
38
     * @return \Symfony\Component\HttpFoundation\Response|SamlSpInfo|null
39
     */
40
    public function manage(Request $request)
41
    {
42
        return $this->httpUtils->createRedirectResponse($request, $request->attributes->get('local_logout_path'));
43
    }
44
}
45