ListBuilderTemplate   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 65
Duplicated Lines 13.85 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 9
loc 65
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFiltersMode() 0 8 2
A getDefaultFiltersVisibility() 0 8 2
A getFiltersModalSize() 0 8 2
A getTemplatesToGenerate() 9 9 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
namespace Admingenerator\GeneratorBundle\Builder\Admin;
4
5
/**
6
 * This builder generates php for lists actions.
7
 *
8
 * @author cedric Lombardot
9
 */
10
class ListBuilderTemplate extends ListBuilder
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $filtersMode = null;
16
17
    /**
18
     * @var string
19
     */
20
    protected $defaultFiltersVisibility = null;
21
22
    /**
23
     * @var string
24
     */
25
    protected $filtersModalSize = null;
26
27
    /**
28
     * Retrieve the filters mode parameter defined into the
29
     * YAML generator file under the list builder.
30
     *
31
     * @return string
32
     */
33
    public function getFiltersMode()
34
    {
35
        if (null === $this->filtersMode) {
36
            $this->filtersMode = $this->getGenerator()->getFromYaml('builders.list.params.filtersMode', 'default');
37
        }
38
39
        return $this->filtersMode;
40
    }
41
42
    public function getDefaultFiltersVisibility()
43
    {
44
        if (null === $this->defaultFiltersVisibility) {
45
            $this->defaultFiltersVisibility = $this->getGenerator()->getFromYaml('builders.list.params.defaultFiltersVisibility', 'expanded');
46
        }
47
48
        return $this->defaultFiltersVisibility;
49
    }
50
51
    public function getFiltersModalSize()
52
    {
53
        if (null === $this->filtersModalSize) {
54
            $this->filtersModalSize = $this->getGenerator()->getFromYaml('builders.list.params.filtersModalSize', 'medium');
55
        }
56
57
        return $this->filtersModalSize;
58
    }
59
60
    /**
61
     * (non-PHPdoc).
62
     *
63
     * @see \Admingenerator\GeneratorBundle\Builder\BaseBuilder::getTemplatesToGenerate()
64
     */
65 View Code Duplication
    public function getTemplatesToGenerate()
0 ignored issues
show
Duplication introduced by
This method 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...
66
    {
67
        return parent::getTemplatesToGenerate() + array(
68
            'ListBuilderTemplate'.self::TWIG_EXTENSION => 'Resources/views/'.$this->getBaseGeneratorName().'List/index.html.twig',
69
            'List/FiltersBuilderTemplate'.self::TWIG_EXTENSION => 'Resources/views/'.$this->getBaseGeneratorName().'List/filters.html.twig',
70
            'List/ResultsBuilderTemplate'.self::TWIG_EXTENSION => 'Resources/views/'.$this->getBaseGeneratorName().'List/results.html.twig',
71
            'List/RowBuilderTemplate'.self::TWIG_EXTENSION => 'Resources/views/'.$this->getBaseGeneratorName().'List/row.html.twig',
72
        );
73
    }
74
}
75