Completed
Push — master ( d67956...a656c9 )
by Piotr
11s
created

FirewallMapper::getFirewallName()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 4
nc 3
nop 1
dl 0
loc 9
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\Bundle\AdminSecurityBundle\Security\Firewall;
11
12
use Symfony\Component\HttpFoundation\Request;
13
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
14
15
class FirewallMapper
16
{
17
    /**
18
     * @var array|RequestMatcherInterface[]
19
     */
20
    private $map;
21
22
    /**
23
     * @param array|RequestMatcherInterface[] $map
24
     */
25
    public function __construct(array $map)
26
    {
27
        $this->map = $map;
28
    }
29
30
    /**
31
     * @param Request $request
32
     * @return string|null
33
     */
34
    public function getFirewallName(Request $request)
35
    {
36
        foreach ($this->map as $firewallName => $requestMatcher) {
37
            if (null === $requestMatcher || $requestMatcher->matches($request)) {
38
                return $firewallName;
39
            }
40
        }
41
42
        return null;
43
    }
44
}
45