PopupAdminListConfigurator   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 88
Duplicated Lines 9.09 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 2
dl 8
loc 88
ccs 0
cts 40
cp 0
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 1
A buildFields() 0 8 1
A buildFilters() 0 5 1
A getBundleName() 0 4 1
A getEntityName() 0 4 1
A canEdit() 0 4 1
A canDelete() 0 4 1
A canAdd() 0 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
namespace Kunstmaan\LeadGenerationBundle\AdminList;
4
5
use Doctrine\ORM\EntityManager;
6
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
7
use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator;
8
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM;
9
10
class PopupAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator
11
{
12
    /**
13
     * @param EntityManager $em        The entity manager
14
     * @param AclHelper     $aclHelper The acl helper
0 ignored issues
show
Documentation introduced by
Should the type for parameter $aclHelper not be null|AclHelper?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
15
     */
16 View Code Duplication
    public function __construct(EntityManager $em, AclHelper $aclHelper = null)
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...
17
    {
18
        parent::__construct($em, $aclHelper);
19
20
        $this->setListTemplate('@KunstmaanLeadGeneration/AdminList/popup-list.html.twig');
21
        $this->setEditTemplate('@KunstmaanLeadGeneration/AdminList/popup-edit.html.twig');
22
        $this->setAddTemplate('@KunstmaanLeadGeneration/AdminList/popup-edit.html.twig');
23
    }
24
25
    /**
26
     * Configure the visible columns
27
     */
28
    public function buildFields()
29
    {
30
        $this->addField('id', 'kuma_lead_generation.popup.list.header.id', true);
31
        $this->addField('name', 'kuma_lead_generation.popup.list.header.name', true);
32
        $this->addField('classname', 'kuma_lead_generation.popup.list.header.type', false);
33
        $this->addField('htmlId', 'kuma_lead_generation.popup.list.header.html_id', true);
34
        $this->addField('ruleCount', 'kuma_lead_generation.popup.list.header.rule_count', false);
35
    }
36
37
    /**
38
     * Build filters for admin list
39
     */
40
    public function buildFilters()
41
    {
42
        $this->addFilter('name', new ORM\StringFilterType('name'), 'kuma_lead_generation.popup.list.filter.name');
43
        $this->addFilter('htmlId', new ORM\StringFilterType('htmlId'), 'kuma_lead_generation.popup.list.filter.html_id');
44
    }
45
46
    /**
47
     * Get bundle name
48
     *
49
     * @return string
50
     */
51
    public function getBundleName()
52
    {
53
        return 'KunstmaanLeadGenerationBundle';
54
    }
55
56
    /**
57
     * Get entity name
58
     *
59
     * @return string
60
     */
61
    public function getEntityName()
62
    {
63
        return 'Popup\AbstractPopup';
64
    }
65
66
    /**
67
     * @param object|array $item
68
     *
69
     * @return bool
70
     */
71
    public function canEdit($item)
72
    {
73
        return true;
74
    }
75
76
    /**
77
     * Configure if it's possible to delete the given $item
78
     *
79
     * @param object|array $item
80
     *
81
     * @return bool
82
     */
83
    public function canDelete($item)
84
    {
85
        return true;
86
    }
87
88
    /**
89
     * Configure if it's possible to add new items
90
     *
91
     * @return bool
92
     */
93
    public function canAdd()
94
    {
95
        return true;
96
    }
97
}
98