UriPatterns   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A matches() 0 9 3
1
<?php
2
namespace Dkplus\CsrfApiUnprotectionBundle\UnprotectionRule;
3
4
use Assert\Assertion;
5
use Symfony\Component\HttpFoundation\Request;
6
7
final class UriPatterns implements UnprotectionRule
8
{
9
    /** @var string[] */
10
    private $patterns;
11
12 6
    public function __construct(array $patterns)
13
    {
14 6
        foreach ($patterns as $each) {
15 5
            Assertion::string($each);
16
        }
17 6
        $this->patterns = $patterns;
18 6
    }
19
20 5
    public function matches(Request $request)
21
    {
22 5
        foreach ($this->patterns as $each) {
23 5
            if (preg_match($each, $request->getRequestUri())) {
24 5
                return true;
25
            }
26
        }
27 2
        return false;
28
    }
29
}
30