GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EcommerceDashboardPanel_OrderStep   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 6
dl 0
loc 44
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getLabelPrefix() 0 4 1
A getConfiguration() 0 6 1
A Content() 0 21 4
A onBeforeWrite() 0 5 1
1
<?php
2
3
class EcommerceDashboardPanel_OrderStep extends EcommerceDashboardPanel
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
    private static $icon = "ecommerce_dashboard/images/icons/EcommerceDashboardPanel_OrderStep.png";
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $icon is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
6
7
    public function getLabelPrefix()
8
    {
9
        return 'Order Journey';
10
    }
11
12
    public function getConfiguration()
13
    {
14
        $fields = parent::getConfiguration();
15
        $fields->replaceField('DaysBack', HiddenField::create('DaysBack', 'DaysBack'));
16
        return $fields;
17
    }
18
19
    public function Content()
20
    {
21
        $html = '';
0 ignored issues
show
Unused Code introduced by
$html is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
22
        $orderSteps = OrderStep::get()->limit(OrderStep::get()->count()-1);
23
        $html = '<ul>';
24
        $done = false;
25
        foreach ($orderSteps as $orderStep) {
26
            $count = Order::get()
27
                ->filter(array('StatusID' => $orderStep->ID, 'CancelledByID' => 0))
28
                ->count();
29
            if ($count > 0) {
30
                $done = true;
31
                $html .= '<li><strong>'.$orderStep->Title.'</strong>: <span>'.$count.'</span><em>'.$orderStep->Description.'</em></li>';
32
            }
33
        }
34
        if ($done === false) {
35
            $html .= '<li>All orders have been archived</li>';
36
        }
37
        $html .= '<ul>';
38
        return $html;
39
    }
40
41
    public function onBeforeWrite()
42
    {
43
        parent::onBeforeWrite();
44
        $this->DaysBack = 0;
0 ignored issues
show
Documentation introduced by
The property DaysBack does not exist on object<EcommerceDashboardPanel_OrderStep>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
45
    }
46
}
47