SameHostPolicy::shouldVisit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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
}