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

ChainFactory   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 56.25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 36
ccs 9
cts 16
cp 0.5625
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A buildChain() 0 9 2
A getScraperDeclarations() 0 6 2
A buildScraper() 0 3 1
A initialize() 0 4 1
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