SameHostPolicy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A shouldVisit() 0 4 1
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
use SiteMap\Http\Url;
14
use SiteMap\Http\UrlUtil;
15
16
class SameHostPolicy implements Policy
17
{
18
    /**
19
     * @var Url
20
     */
21
    private $baseUrl;
22
23
    /**
24
     * SameHostPolicy constructor.
25
     * @param Url $baseUrl
26
     */
27
    public function __construct(Url $baseUrl)
28
    {
29
        $this->baseUrl = $baseUrl;
30
    }
31
32
    /**
33
     * @param Url $url
34
     * @return bool
35
     */
36
    public function shouldVisit(Url $url)
37
    {
38
        return UrlUtil::checkSameHost($this->baseUrl, $url);
39
    }
40
}