Completed
Pull Request — master (#35)
by Krzysztof
04:21
created

TransformerCompilerPass::processParam()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 9.6666
cc 2
eloc 6
nc 2
nop 3
crap 2
1
<?php
2
3
namespace KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
7
/**
8
 * @author Krzysztof Gzocha <[email protected]>
9
 */
10
class TransformerCompilerPass extends AbstractChainsCompilerPass
11
{
12
    /**
13
     * @inheritDoc
14
     */
15 2
    protected function processParam(
16
        $contextId,
17
        array &$paramConfig,
18
        ContainerBuilder $container
19
    ) {
20 2
        foreach ($paramConfig['transformers'] as &$transformer) {
21 2
            $this->processTransformer($contextId, $transformer, $container);
22
        }
23 2
    }
24
25
    /**
26
     * @param string           $contextId
27
     * @param array            $transformer
28
     * @param ContainerBuilder $container
29
     */
30 2
    private function processTransformer(
31
        $contextId,
32
        array &$transformer,
33
        ContainerBuilder $container
34
    ) {
35 2
        $this->buildDefinition(
36
            $container,
37
            $contextId,
38 2
            $this->buildChainServiceName(
39
                $contextId,
40 2
                sprintf('%s.%s', self::TRANSFORMER_PARAMETER, $transformer[self::NAME_PARAMETER])
41
            ),
42
            $transformer
43
        );
44 2
    }
45
}
46