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

TransformerCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 36
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processParam() 0 9 2
A processTransformer() 0 15 1
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