KGzochaSearcherBundle::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 51
Code Lines 36

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 51
ccs 16
cts 16
cp 1
rs 9.4109
c 0
b 0
f 0
cc 1
eloc 36
nc 1
nop 1
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace KGzocha\Bundle\SearcherBundle;
4
5
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\CellCollectionCompilerPass;
6
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\CellCompilerPass;
7
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\ChainSearchCompilerPass;
8
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\CriteriaBuilderCollectionCompilerPass;
9
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\CriteriaBuilderCompilerPass;
10
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\CriteriaCollectionCompilerPass;
11
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\CriteriaCompilerPass;
12
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\DefinitionBuilder;
13
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\ParametersValidator;
14
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\SearcherCompilerPass;
15
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\SearchingContextCompilerPass;
16
use KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass\TransformerCompilerPass;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\HttpKernel\Bundle\Bundle;
19
20
/**
21
 * @author Krzysztof Gzocha <[email protected]>
22
 */
23
class KGzochaSearcherBundle extends Bundle
24
{
25
    /**
26
     * @param ContainerBuilder $container
27
     */
28 1
    public function build(ContainerBuilder $container)
29
    {
30 1
        parent::build($container);
31 1
        $parametersValidator = new ParametersValidator();
32 1
        $builder = new DefinitionBuilder($parametersValidator);
33 1
        $servicePrefix = $this->getContainerExtension()->getAlias();
34
35 1
        $container->addCompilerPass(new CriteriaCollectionCompilerPass(
36
            $builder,
37
            $servicePrefix
38
        ));
39 1
        $container->addCompilerPass(new CriteriaBuilderCollectionCompilerPass(
40
            $builder,
41
            $servicePrefix
42
        ));
43 1
        $container->addCompilerPass(new CriteriaBuilderCompilerPass(
44
            $builder,
45
            $servicePrefix
46
        ));
47 1
        $container->addCompilerPass(new CriteriaCompilerPass(
48
            $builder,
49
            $servicePrefix
50
        ));
51 1
        $container->addCompilerPass(new SearchingContextCompilerPass(
52
            $builder,
53
            $servicePrefix
54
        ));
55 1
        $container->addCompilerPass(new SearcherCompilerPass(
56
            $builder,
57
            $servicePrefix,
58
            $parametersValidator
59
        ));
60
61
        // Chain search compiler passes
62 1
        $container->addCompilerPass(new CellCompilerPass(
63
            $builder,
64
            $servicePrefix
65
        ));
66 1
        $container->addCompilerPass(new TransformerCompilerPass(
67
            $builder,
68
            $servicePrefix
69
        ));
70 1
        $container->addCompilerPass(new CellCollectionCompilerPass(
71
            $builder,
72
            $servicePrefix
73
        ));
74 1
        $container->addCompilerPass(new ChainSearchCompilerPass(
75
            $builder,
76
            $servicePrefix
77
        ));
78 1
    }
79
}
80