Completed
Push — master ( f641a7...bf0d30 )
by Beñat
02:09
created

AllFilesQueryBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 38
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 16 16 1
A definitionName() 4 4 1
A aliasDefinitionName() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\File\Application\Query\AllFilesHandler;
16
use Symfony\Component\DependencyInjection\Definition;
17
18
/**
19
 * All files query builder.
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 */
23 View Code Duplication
class AllFilesQueryBuilder extends QueryBuilder
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
     * {@inheritdoc}
27
     */
28
    public function register($file)
29
    {
30
        $this->container->setDefinition(
31
            $this->definitionName($file),
32
            new Definition(
33
                AllFilesHandler::class, [
34
                    $this->container->getDefinition(
35
                        'bengor.file.infrastructure.persistence.' . $file . '_repository'
36
                    ),
37
                    $this->container->getDefinition(
38
                        'bengor.file.application.data_transformer.' . $file . '_dto'
39
                    ),
40
                ]
41
            )
42
        );
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    protected function definitionName($file)
49
    {
50
        return 'bengor.file.application.query.all_' . $file . 's';
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function aliasDefinitionName($file)
57
    {
58
        return 'bengor_file.' . $file . '.all_query';
59
    }
60
}
61