Completed
Pull Request — master (#223)
by Andrzej
06:09 queued 04:56
created

CrawlSubdomains::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 2
nop 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A CrawlSubdomains::isSubdomainOfHost() 0 4 1
1
<?php
2
3
namespace Spatie\Crawler;
4
5
use Psr\Http\Message\UriInterface;
6
7
class CrawlSubdomains extends CrawlProfile
8
{
9
    public function shouldCrawl(UriInterface $url): bool
10
    {
11
        return $this->isSubdomainOfHost($url);
12
    }
13
14
    public function isSubdomainOfHost(UriInterface $url): bool
15
    {
16
        return substr($url->getHost(), -strlen($this->baseUrl->getHost())) === $this->baseUrl->getHost();
17
    }
18
}
19