Passed
Pull Request — master (#16)
by
unknown
14:00
created

AbstractHtmlScraper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Aoe\Asdis\Content\Scraper\Html;
4
5
use Aoe\Asdis\Content\Scraper\Extractor\XmlTagAttribute;
6
use Aoe\Asdis\Domain\Model\Asset\Collection;
7
use Aoe\Asdis\Domain\Model\Asset\Factory;
8
9
/**
10
 * Abstract scraper which provides general functionality to scrape paths from HTML tag attributes.
11
 */
12
abstract class AbstractHtmlScraper
13
{
14
    private ?XmlTagAttribute $xmlTagAttributeExtractor = null;
15
    private ?Factory $assetFactory = null;
16
17
    public function __construct(XmlTagAttribute $xmlTagAttributeExtractor, Factory $assetFactory) {
18
        $this->xmlTagAttributeExtractor = $xmlTagAttributeExtractor;
19
        $this->assetFactory = $assetFactory;
20
    }
21
22
    /*
23
    public function injectXmlTagAttributeExtractor(XmlTagAttribute $xmlTagAttributeExtractor): void
24
    {
25
        $this->xmlTagAttributeExtractor = $xmlTagAttributeExtractor;
26 10
    }
27
28 10
    public function injectAssetFactory(Factory $assetFactory): void
29 10
    {
30
        $this->assetFactory = $assetFactory;
31
    }
32
    */
33
34 10
    protected function getAssets(string $tagName, string $attributeName, string $content, array $requiredOtherAttributes = []): ?Collection
35
    {
36 10
        $attributes = $this->xmlTagAttributeExtractor->getAttributeFromTag(
0 ignored issues
show
Bug introduced by
The method getAttributeFromTag() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        /** @scrutinizer ignore-call */ 
37
        $attributes = $this->xmlTagAttributeExtractor->getAttributeFromTag(

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37 10
            $tagName,
38
            $attributeName,
39
            $content,
40
            $requiredOtherAttributes
41
        );
42
        return $this->assetFactory->createAssetsFromPaths(
0 ignored issues
show
Bug introduced by
The method createAssetsFromPaths() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        return $this->assetFactory->/** @scrutinizer ignore-call */ createAssetsFromPaths(

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
            $attributes['paths'],
44
            $attributes['masks']
45
        );
46 10
    }
47
}
48