CrawlInternalUrls::shouldCrawl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Spatie\Crawler;
4
5
use GuzzleHttp\Psr7\Uri;
6
use Psr\Http\Message\UriInterface;
7
8
class CrawlInternalUrls extends CrawlProfile
9
{
10
    protected $baseUrl;
11
12
    public function __construct($baseUrl)
13
    {
14
        if (! $baseUrl instanceof UriInterface) {
15
            $baseUrl = new Uri($baseUrl);
16
        }
17
18
        $this->baseUrl = $baseUrl;
19
    }
20
21
    public function shouldCrawl(UriInterface $url): bool
22
    {
23
        return $this->baseUrl->getHost() === $url->getHost();
24
    }
25
}
26