MixedContentObserver::crawlFailed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Spatie\MixedContentScanner;
4
5
use Spatie\Crawler\CrawlObserver;
6
use Psr\Http\Message\UriInterface;
7
use Psr\Http\Message\ResponseInterface;
8
use GuzzleHttp\Exception\RequestException;
9
10
class MixedContentObserver extends CrawlObserver
11
{
12
    public function crawled(UriInterface $url, ResponseInterface $response, ?UriInterface $foundOnUrl = null)
13
    {
14
        $mixedContent = MixedContentExtractor::extract((string) $response->getBody(), $url);
15
16
        if (! count($mixedContent)) {
17
            $this->noMixedContentFound($url);
18
19
            return;
20
        }
21
22
        foreach ($mixedContent as $mixedContentItem) {
23
            $this->mixedContentFound($mixedContentItem);
24
        }
25
    }
26
27
    public function crawlFailed(
28
        UriInterface $url,
29
        RequestException $requestException,
30
        ?UriInterface $foundOnUrl = null
31
    ) {
32
    }
33
34
    /**
35
     * Will be called when mixed content was found.
36
     *
37
     * @param \Spatie\MixedContentScanner\MixedContent $mixedContent
38
     */
39
    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...
40
    {
41
    }
42
43
    /**
44
     * Will be called when no mixed content was found on the given url.
45
     *
46
     * @param \Psr\Http\Message\UriInterface
47
     */
48
    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...
49
    {
50
    }
51
}
52