Completed
Pull Request — master (#37)
by Andreas
03:05
created

IconUri::parse()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Copyright Andrea Heigl <[email protected]>
7
 *
8
 * Licenses under the MIT-license. For details see the included file LICENSE.md
9
 */
10
namespace Callingallpapers\Subcommands\Sessionize\Parser;
11
12
use DOMDocument;
13
use DOMXPath;
14
15 View Code Duplication
class IconUri
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    private $baseUri;
18
19
    public function __construct(string $baseUri)
20
    {
21
        $this->baseUri  = $baseUri;
22
    }
23
24
    public function parse(DOMDocument $dom, DOMXPath $xpath) : string
0 ignored issues
show
Unused Code introduced by
The parameter $dom 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...
25
    {
26
        $uriPath = $xpath->query('//div[contains(@class, "ibox-content")]/img');
27
28
        if (! $uriPath || $uriPath->length == 0) {
29
            throw new \InvalidArgumentException('The CfP does not seem to have an Icon');
30
        }
31
32
        return $uriPath->item(0)->attributes->getNamedItem('src')->textContent;
33
    }
34
}
35