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

FirewallMapper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFirewallName() 0 9 4
A __construct() 0 3 1
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