QueryBuilder::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the BenGorFile package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorFile\FileBundle\DependencyInjection\Compiler\Application\Query;
14
15
use BenGorFile\FileBundle\DependencyInjection\Compiler\Application\ApplicationBuilder;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
/**
19
 * Base query builder.
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 */
23 View Code Duplication
abstract class QueryBuilder implements ApplicationBuilder
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...
24
{
25
    /**
26
     * Configuration array.
27
     *
28
     * @var array
29
     */
30
    protected $configuration;
31
32
    /**
33
     * The container builder.
34
     *
35
     * @var ContainerBuilder
36
     */
37
    protected $container;
38
39
    /**
40
     * Constructor.
41
     *
42
     * @param ContainerBuilder $container     The container builder
43
     * @param array            $configuration The configuration tree
44
     */
45
    public function __construct(ContainerBuilder $container, array $configuration = [])
46
    {
47
        $this->container = $container;
48
        $this->configuration = $configuration;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function build($file)
55
    {
56
        $this->register($file);
57
58
        $this->container->setAlias(
59
            $this->aliasDefinitionName($file),
60
            $this->definitionName($file)
61
        );
62
63
        return $this->container;
64
    }
65
66
    /**
67
     * Gets the query definition name.
68
     *
69
     * @param string $file The file name
70
     *
71
     * @return string
72
     */
73
    abstract protected function definitionName($file);
74
75
    /**
76
     * Gets the query definition name alias.
77
     *
78
     * @param string $file The file name
79
     *
80
     * @return string
81
     */
82
    abstract protected function aliasDefinitionName($file);
83
84
    /**
85
     * Registers the query into container.
86
     *
87
     * @param string $file The file name
88
     */
89
    abstract protected function register($file);
90
}
91