EquipmentCustomer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 63
loc 63
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A getForm() 7 7 1
A getGroupsRead() 6 6 1
A getGroupsSubmit() 6 6 1
A getGroupsModeration() 6 6 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
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
13
/**
14
 * Module: Equipment
15
 *
16
 * @category        Module
17
 * @package         equipment
18
 * @author          XOOPS Development Team <[email protected]> - <http://xoops.org>
19
 * @copyright       {@link https://xoops.org/ XOOPS Project}
20
 * @license         GPL 2.0 or later
21
 * @link            https://xoops.org/
22
 * @since           1.0.0
23
 */
24
25
use Xmf\Module\Helper\Permission;
26
27
$moduleDirName = basename(dirname(__DIR__));
28
29
$permHelper = new Permission($moduleDirName);
30
31
/**
32
 * Class EquipmentCustomer
33
 */
34 View Code Duplication
class EquipmentCustomer extends XoopsObject
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...
35
{
36
    /**
37
     * Constructor
38
     *
39
     * @param null
40
     */
41
    public function __construct()
42
    {
43
        parent::__construct();
44
        $this->initVar('id', XOBJ_DTYPE_INT);
45
        $this->initVar('first', XOBJ_DTYPE_TXTBOX);
46
        $this->initVar('last', XOBJ_DTYPE_TXTBOX);
47
        $this->initVar('address', XOBJ_DTYPE_TXTBOX);
48
        $this->initVar('city', XOBJ_DTYPE_TXTBOX);
49
        $this->initVar('country', XOBJ_DTYPE_TXTBOX);
50
        $this->initVar('created', XOBJ_DTYPE_TIMESTAMP);
51
    }
52
53
    /**
54
     * Get form
55
     *
56
     * @param null
57
     * @return EquipmentCustomerForm
58
     */
59
    public function getForm()
60
    {
61
        require_once XOOPS_ROOT_PATH . '/modules/equipment/class/form/customer.php';
62
63
        $form = new EquipmentCustomerForm($this);
64
        return $form;
65
    }
66
67
    /**
68
     * @return array|null
69
     */
70
    public function getGroupsRead()
71
    {
72
        global $permHelper;
73
        //return $this->publisher->getHandler('permission')->getGrantedGroupsById('customer_read', id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
74
        return $permHelper->getGroupsForItem('sbcolumns_read', $this->getVar('id'));
75
    }
76
77
    /**
78
     * @return array|null
79
     */
80
    public function getGroupsSubmit()
81
    {
82
        global $permHelper;
83
        //        return $this->publisher->getHandler('permission')->getGrantedGroupsById('customer_submit', id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
84
        return $permHelper->getGroupsForItem('sbcolumns_submit', $this->getVar('id'));
85
    }
86
87
    /**
88
     * @return array|null
89
     */
90
    public function getGroupsModeration()
91
    {
92
        global $permHelper;
93
        //        return $this->publisher->getHandler('permission')->getGrantedGroupsById('customer_moderation', id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
94
        return $permHelper->getGroupsForItem('sbcolumns_moderation', $this->getVar('id'));
95
    }
96
}
97
98
/**
99
 * Class EquipmentCustomerHandler
100
 */
101
class EquipmentCustomerHandler extends XoopsPersistableObjectHandler
102
{
103
    /**
104
     * Constructor
105
     * @param null|XoopsDatabase $db
106
     */
107
108
    public function __construct(XoopsDatabase $db)
109
    {
110
        parent::__construct($db, 'equipment_customer', 'EquipmentCustomer', 'id', 'last');
111
    }
112
}
113