Completed
Pull Request — master (#223)
by Andrzej
06:41
created

CrawlSubdomains   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

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