OneDayAdminRoles   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 55.77 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 0
dl 29
loc 52
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toOptionArray() 15 15 2
A toArray() 14 14 2
A getAdminRolesCollection() 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
class Qrz_OneDayAdmin_Model_System_Config_Source_OneDayAdminRoles
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
    /**
7
     * @return array
8
     * @author Cristian Quiroz <[email protected]>
9
     */
10 View Code Duplication
    public function toOptionArray()
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...
11
    {
12
        $rolesCollection = $this->getAdminRolesCollection();
13
        $rolesArray = array();
14
15
        foreach ($rolesCollection as $role) {
16
            /** @var Mage_Admin_Model_Role $role */
17
            $rolesArray[] = array(
18
                'value' => $role->getRoleName(),
19
                'label' => $role->getRoleName(),
20
            );
21
        }
22
23
        return $rolesArray;
24
    }
25
26
    /**
27
     * Get options in "key => value" format
28
     * @return array
29
     * @author Cristian Quiroz <[email protected]>
30
     */
31 View Code Duplication
    public function toArray()
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...
32
    {
33
        $rolesCollection = $this->getAdminRolesCollection();
34
        $rolesArray = array();
35
36
        foreach ($rolesCollection as $role) {
37
            /** @var Mage_Admin_Model_Role $role */
38
            $rolesArray[] = array(
39
                $role->getRoleName() => $role->getRoleName(),
40
            );
41
        }
42
43
        return $rolesArray;
44
    }
45
46
    /**
47
     * @return Mage_Admin_Model_Resource_Roles_Collection
48
     * @author Cristian Quiroz <[email protected]>
49
     */
50
    protected function getAdminRolesCollection()
51
    {
52
        return Mage::getModel('admin/roles')->getCollection();
53
    }
54
}
55