ChainFactory::buildChain()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 9
ccs 5
cts 6
cp 0.8333
crap 2.0185
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Aoe\Asdis\Content\Scraper;
3
4
use Aoe\Asdis\Content\Scraper\Chain;
5
use Aoe\Asdis\Content\Scraper\ScraperInterface;
6
use Aoe\Asdis\System\Factory\AbstractDeclarationBasedFactory;
7
8
/**
9
 * Scraper chain factory.
10
 */
11
class ChainFactory extends AbstractDeclarationBasedFactory
12
{
13
    /**
14
     * @return \Aoe\Asdis\Content\Scraper\Chain
15
     */
16 1
    public function buildChain()
17
    {
18 1
        $this->initialize();
19
        /** @var \Aoe\Asdis\Content\Scraper\Chain $chain */
20 1
        $chain = $this->objectManager->get(Chain::class);
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\CMS\Extbase\Object...ManagerInterface::get() has been deprecated: since TYPO3 10.4, will be removed in version 12.0 ( Ignorable by Annotation )

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

20
        $chain = /** @scrutinizer ignore-deprecated */ $this->objectManager->get(Chain::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
21 1
        foreach($this->configurationProvider->getScraperKeys() as $scraperKey) {
22
            $chain->append($this->buildScraper($scraperKey));
23
        }
24 1
        return $chain;
25
    }
26
27
    /**
28
     * @return void
29
     */
30 1
    private function initialize()
31
    {
32 1
        $this->setDeclarations($this->getScraperDeclarations());
33 1
        $this->setClassImplements(['Aoe\Asdis\Content\Scraper\ScraperInterface']);
34 1
    }
35
36
    /**
37
     * @param string $scraperKey
38
     * @return \Aoe\Asdis\Content\Scraper\ScraperInterface
39
     */
40
    private function buildScraper($scraperKey)
41
    {
42
        return $this->buildObjectFromKey($scraperKey);
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    protected function getScraperDeclarations()
49
    {
50
        if (false === isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['asdis']['scrapers'])) {
51
            return array();
52
        }
53
        return $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['asdis']['scrapers'];
54
    }
55
}