Passed
Push — master ( e0b1d7...ca5e79 )
by Matthijs
07:20
created

UriFilter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A match() 0 9 3
1
<?php
2
namespace VDB\Spider\Filter\Prefetch;
3
4
use VDB\Spider\Filter\PreFetchFilterInterface;
5
use VDB\Uri\UriInterface;
6
7
/**
8
 * @author matthijs
9
 */
10
class UriFilter implements PreFetchFilterInterface
11
{
12
    /**
13
     * @var array An array of regexes
14
     */
15
    public $regexes = array();
16
17
    public function __construct(array $regexes = array())
18
    {
19
        $this->regexes = $regexes;
20
    }
21
22
    public function match(UriInterface $uri)
23
    {
24
        foreach ($this->regexes as $regex) {
25
            if (preg_match($regex, $uri->toString())) {
26
                return true;
27
            }
28
        }
29
        return false;
30
    }
31
}
32