ValidExtensionPolicy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A shouldVisit() 0 13 2
1
<?php
2
/**
3
 * This file is part of sitemap-common.
4
 *
5
 * (c) 2016 Daniele Moraschi
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace SiteMap\Policy;
12
13
14
use SiteMap\Http\Url;
15
16
class ValidExtensionPolicy implements Policy
17
{
18
    
19
    const FILTER = ".*(\\.(css|js|gif|jpg|jpeg|png|mp3|zip|gz|tar|7z))";
20
21
    /**
22
     * @param Url $url
23
     * @return bool
24
     */
25
    public function shouldVisit(Url $url)
26
    {
27
        if (preg_match_all(
28
                "/" . self::FILTER . "/siU",
29
                $url->getWebUrl(),
30
                $matches,
31
                PREG_SET_ORDER
32
            ) === 0) {
33
            return true;
34
        }
35
36
        return false;
37
    }
38
}