Passed
Pull Request — master (#16)
by
unknown
13:19 queued 10:34
created

ChainFactory::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Aoe\Asdis\Content\Scraper;
4
5
use Aoe\Asdis\System\Factory\AbstractDeclarationBasedFactory;
6
use TYPO3\CMS\Core\Utility\GeneralUtility;
7
8
/**
9
 * Scraper chain factory.
10
 */
11
class ChainFactory extends AbstractDeclarationBasedFactory
12
{
13
    /**
14
     * @return Chain
15
     */
16 1
    public function buildChain()
17
    {
18 1
        $this->initialize();
19
        /** @var Chain $chain */
20 1
        $chain = GeneralUtility::makeInstance(Chain::class);
21 1
        foreach ($this->configurationProvider->getScraperKeys() as $scraperKey) {
0 ignored issues
show
Bug introduced by
The method getScraperKeys() 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

21
        foreach ($this->configurationProvider->/** @scrutinizer ignore-call */ getScraperKeys() as $scraperKey) {

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...
22
            $chain->append($this->buildScraper($scraperKey));
23
        }
24 1
        return $chain;
25
    }
26
27
    protected function getScraperDeclarations(): array
28
    {
29
        if (!isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['asdis']['scrapers'])) {
30
            return [];
31
        }
32
        return $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['asdis']['scrapers'];
33
    }
34
35 1
    private function initialize(): void
36
    {
37 1
        $this->setDeclarations($this->getScraperDeclarations());
38 1
        $this->setClassImplements([ScraperInterface::class]);
39 1
    }
40
41
    /**
42
     * @return ScraperInterface
43
     */
44
    private function buildScraper(string $scraperKey)
45
    {
46
        return $this->buildObjectFromKey($scraperKey);
47
    }
48
}
49