MixedContent::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Spatie\MixedContentScanner;
4
5
use Psr\Http\Message\UriInterface;
6
7
class MixedContent
8
{
9
    /** string */
10
    public $elementName = '';
11
12
    /** @var\Spatie\Crawler\Url */
13
    public $mixedContentUrl = null;
14
15
    /** @var\Spatie\Crawler\Url */
16
    public $foundOnUrl = null;
17
18
    public function __construct(string $elementName, UriInterface $mixedContentUrl, UriInterface $foundOnUrl)
19
    {
20
        $this->elementName = $elementName;
21
22
        if ($mixedContentUrl->getPath() === '') {
23
            $mixedContentUrl = $mixedContentUrl->withPath('/');
24
        }
25
26
        $this->mixedContentUrl = $mixedContentUrl;
27
28
        if ($foundOnUrl->getPath() === '') {
29
            $foundOnUrl = $foundOnUrl->withPath('/');
30
        }
31
32
        $this->foundOnUrl = $foundOnUrl;
33
    }
34
35
    public function toArray(): array
36
    {
37
        return [
38
            'elementName' => $this->elementName,
39
            'mixedContentUrl' => (string) $this->mixedContentUrl,
40
            'foundOnUrl' => (string) $this->foundOnUrl,
41
        ];
42
    }
43
}
44