Completed
Push — master ( e4dffe...da1dc4 )
by Freek
01:29
created

MixedContentScanner::setCrawlProfile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Spatie\MixedContentScanner;
4
5
use Spatie\Crawler\Crawler;
6
use Spatie\Crawler\CrawlProfile;
7
use Spatie\Crawler\CrawlInternalUrls;
8
9
class MixedContentScanner
10
{
11
    /** @var \Spatie\MixedContentScanner\MixedContentObserver */
12
    public $mixedContentObserver;
13
14
    /** @var null|\Spatie\Crawler\CrawlProfile */
15
    public $crawlProfile;
16
17
    public function __construct(MixedContentObserver $mixedContentObserver)
18
    {
19
        $this->mixedContentObserver = $mixedContentObserver;
20
    }
21
22
    public function scan(string $url, array $clientOptions = [])
23
    {
24
        Crawler::create($clientOptions)
25
            ->setCrawlProfile($this->crawlProfile ?? new CrawlInternalUrls($url))
26
            ->setCrawlObserver($this->mixedContentObserver)
27
            ->startCrawling($url);
28
    }
29
30
    public function setCrawlProfile(CrawlProfile $crawlProfile)
31
    {
32
        $this->crawlProfile = $crawlProfile;
33
34
        return $this;
35
    }
36
}
37