Passed
Pull Request — master (#16)
by
unknown
03:22
created

ChainFactory   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 56.25%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getScraperDeclarations() 0 6 2
A buildChain() 0 8 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 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