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

MixedContentObserver   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 44
rs 10
c 2
b 0
f 0

4 Methods

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