ChainFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 40
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A buildFilter() 0 3 1
A initialize() 0 4 1
A getDeclarations() 0 3 1
A buildChain() 0 9 2
1
<?php
2
namespace Aoe\Asdis\System\Uri\Filter;
3
4
use Aoe\Asdis\System\Factory\AbstractDeclarationBasedFactory;
5
use Aoe\Asdis\System\Uri\Filter\Chain;
6
use Aoe\Asdis\System\Uri\Filter\FilterInterface;
7
8
/**
9
 * Factory for filter chains.
10
 */
11
class ChainFactory extends AbstractDeclarationBasedFactory
12
{
13
    /**
14
     * @return \Aoe\Asdis\System\Uri\Filter\Chain
15
     */
16 1
    public function buildChain()
17
    {
18 1
        $this->initialize();
19
        /** @var \Aoe\Asdis\System\Uri\Filter\Chain $chain */
20 1
        $chain = new Chain();
21 1
        foreach ($this->configurationProvider->getFilterKeys() as $filterKey) {
22 1
            $chain->append($this->buildFilter($filterKey));
23
        }
24 1
        return $chain;
25
    }
26
27
    /**
28
     * @return void
29
     */
30 1
    private function initialize()
31
    {
32 1
        $this->setDeclarations($this->getDeclarations());
33 1
        $this->setClassImplements([FilterInterface::class]);
34 1
    }
35
36
    /**
37
     * @param string $filterKey
38
     * @return \Aoe\Asdis\System\Uri\Filter\FilterInterface
39
     */
40 1
    private function buildFilter($filterKey)
41
    {
42 1
        return $this->buildObjectFromKey($filterKey);
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    protected function getDeclarations()
49
    {
50
        return $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['asdis']['filters'];
51
    }
52
}