Completed
Push — master ( 7008b1...7663ef )
by Freek
01:19
created

MixedContentObserver::finishedCrawling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Spatie\MixedContentScanner;
4
5
use Spatie\Crawler\Url;
6
use Spatie\Crawler\EmptyCrawlObserver;
7
8
class MixedContentObserver extends EmptyCrawlObserver
9
{
10
    public function hasBeenCrawled(Url $crawledUrl, $response, Url $foundOnUrl = null)
11
    {
12
        if (! $response) {
13
            $this->didNotRespond($crawledUrl, $response);
0 ignored issues
show
Unused Code introduced by
The call to MixedContentObserver::didNotRespond() has too many arguments starting with $response.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
14
15
            return;
16
        }
17
18
        $mixedContent = MixedContentExtractor::extract((string) $response->getBody(), $crawledUrl);
19
20
        if (! count($mixedContent)) {
21
            $this->noMixedContentFound($crawledUrl);
22
23
            return;
24
        }
25
26
        foreach ($mixedContent as $mixedContentItem) {
27
            $this->mixedContentFound($mixedContentItem);
28
        }
29
    }
30
31
    /**
32
     * Will be called when the host did not give a response for the given url.
33
     *
34
     * @param \Spatie\Crawler\Url $crawledUrl
35
     */
36
    public function didNotRespond(Url $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...
37
    {
38
    }
39
40
    /**
41
     * Will be called when mixed content was found.
42
     *
43
     * @param \Spatie\MixedContentScanner\MixedContent $mixedContent
44
     */
45
    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...
46
    {
47
    }
48
49
    /**
50
     * Will be called when no mixed content was found on the given url.
51
     *
52
     * @param \Spatie\Crawler\Url $crawledUrl
53
     */
54
    public function noMixedContentFound(Url $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...
55
    {
56
    }
57
}
58