CountryPrice_OrderStatusLog_AND_OrderAtribute   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 27
Duplicated Lines 37.04 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A canCreate() 0 4 1
B canView() 10 15 7
A canEdit() 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 CountryPrice_OrderStatusLog_AND_OrderAtribute extends DataExtension
4
{
5
    public function canCreate($member = null)
6
    {
7
        return true;
8
    }
9
    public function canView($member = null)
10
    {
11
        if (! $this->owner->ID) {
0 ignored issues
show
Bug introduced by
The property ID does not seem to exist in SS_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
12
            return true;
13 View Code Duplication
        } elseif ($member && $member->DistributorID) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
14
            if ($order = $this->owner->Order()) {
15
                $distributor = $order->Distributor();
16
                if ($distributor) {
17
                    if ($distributor->ID == $member->DistributorID) {
18
                        return true;
19
                    }
20
                }
21
            }
22
        }
23
    }
24
25
    public function canEdit($member = null)
26
    {
27
        return $this->canView($member);
28
    }
29
}
30