Completed
Push — master ( dc17ac...89d057 )
by Freek
06:06
created

MixedContentObserver::crawled()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 3
1
<?php
2
3
namespace Spatie\MixedContentScanner;
4
5
use GuzzleHttp\Exception\RequestException;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\UriInterface;
8
use Spatie\Crawler\CrawlObserver;
9
use Spatie\Crawler\EmptyCrawlObserver;
10
11
class MixedContentObserver extends CrawlObserver
12
{
13
    public function crawled(UriInterface $url, ResponseInterface $response, ?UriInterface $foundOnUrl = null)
14
    {
15
        $mixedContent = MixedContentExtractor::extract((string) $response->getBody(), $url);
16
17
        if (! count($mixedContent)) {
18
            $this->noMixedContentFound($url);
19
20
            return;
21
        }
22
23
        foreach ($mixedContent as $mixedContentItem) {
24
            $this->mixedContentFound($mixedContentItem);
25
        }
26
    }
27
28
    public function crawlFailed(
29
        UriInterface $url,
30
        RequestException $requestException,
31
        ?UriInterface $foundOnUrl = null
32
    )
33
    {
34
35
    }
36
37
    /**
38
     * Will be called when mixed content was found.
39
     *
40
     * @param \Spatie\MixedContentScanner\MixedContent $mixedContent
41
     */
42
    public function mixedContentFound(MixedContent $mixedContent)
0 ignored issues
show
Unused Code introduced by
The parameter $mixedContent is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
    {
44
    }
45
46
    /**
47
     * Will be called when no mixed content was found on the given url.
48
     *
49
     * @param \Psr\Http\Message\UriInterface
50
     */
51
    public function noMixedContentFound(UriInterface $crawledUrl)
0 ignored issues
show
Unused Code introduced by
The parameter $crawledUrl is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    {
53
    }
54
}
55