Completed
Pull Request — master (#34)
by Krzysztof
03:53
created

processContext()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 17

Duplication

Lines 26
Ratio 100 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 26
loc 26
ccs 12
cts 12
cp 1
rs 8.8571
cc 2
eloc 17
nc 2
nop 3
crap 2
1
<?php
2
3
namespace KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Definition;
7
8
/**
9
 * @author Krzysztof Gzocha <[email protected]>
10
 */
11 View Code Duplication
class CriteriaBuilderCollectionCompilerPass extends AbstractCompilerPass
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 12
    protected function processContext(
17
        $contextId,
18
        array &$context,
19
        ContainerBuilder $container
20
    ) {
21 12
        $config = $context[self::BUILDER_COLLECTION_PARAMETER];
22 12
        $this->validateParameters($contextId, $config);
23
24 12
        if (isset($config[self::SERVICE_PARAMETER])) {
25 2
            $this->checkIfServiceExists(
26
                $container,
27
                $contextId,
28 2
                $config[self::SERVICE_PARAMETER]
29
            );
30
31 1
            return $container->setDefinition(
32 1
                $this->buildServiceName($contextId, self::BUILDER_COLLECTION_PARAMETER),
33 1
                $container->getDefinition($config[self::SERVICE_PARAMETER])
34
            );
35
        }
36
37 10
        return $container->setDefinition(
38 10
            $this->buildServiceName($contextId, self::BUILDER_COLLECTION_PARAMETER),
39 10
            new Definition($config[self::CLASS_PARAMETER])
40
        );
41
    }
42
}
43