UriFilter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

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