Completed
Push — master ( b1ef3d...54d3e2 )
by Freek
01:12
created

MixedContentScanner   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A scan() 0 7 1
A useCrawlProfile() 0 4 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 useCrawlProfile(CrawlProfile $crawlProfile)
31
    {
32
        $this->crawlProfile = $crawlProfile;
33
    }
34
}
35