Passed
Pull Request — master (#16)
by
unknown
03:22
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 1
        $chain = GeneralUtility::makeInstance(Chain::class);
20 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

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