MixedContentObserver   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 42
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A crawled() 0 14 3
A crawlFailed() 0 6 1
A mixedContentFound() 0 3 1
A noMixedContentFound() 0 3 1
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