Completed
Push — master ( 8c68ea...ca6a09 )
by Krzysztof
03:33
created

ContextsCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 92.31%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 30 3
1
<?php
2
3
namespace KGzocha\Bundle\SearcherBundle\DependencyInjection;
4
5
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\Criteria;
6
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\CriteriaBuilder;
7
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\CriteriaBuilderCollection;
8
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\CriteriaCollection;
9
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\Searcher;
10
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\SearchingContext;
11
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
14
/**
15
 * @author Krzysztof Gzocha <[email protected]>
16
 */
17
class ContextsCompilerPass implements CompilerPassInterface
18
{
19
    /**
20
     * @inheritDoc
21
     */
22 1
    public function process(ContainerBuilder $container)
23
    {
24 1
        $contextParam = 'k_gzocha_searcher.contexts';
25 1
        if (!$container->hasParameter($contextParam)) {
26
            throw new \InvalidArgumentException('Contexts are missing from the configuration.');
27
        }
28
29 1
        $contexts = $container->getParameter($contextParam);
30
31 1
        foreach ($contexts as $contextId => &$context) {
32 1
            CriteriaCollection::defineServices(
33
                $contextId, $context, $container
34
            );
35 1
            CriteriaBuilderCollection::defineServices(
36
                $contextId, $context, $container
37
            );
38 1
            Criteria::defineServices(
39
                $contextId, $context, $container
40
            );
41 1
            CriteriaBuilder::defineServices(
42
                $contextId, $context, $container
43
            );
44 1
            SearchingContext::defineServices(
45
                $contextId, $context, $container
46
            );
47 1
            Searcher::defineServices(
48
                $contextId, $context, $container
49
            );
50
        }
51 1
    }
52
}
53