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.
Completed
Push — master ( 0d2b0f...270854 )
by Nicolaas
01:24
created

getConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
4
class EcommerceDashboardPanel_IncompletePayments 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...
5
{
6
    private static $icon = "ecommerce_dashboard/images/icons/EcommerceDashboardPanel_IncompletePayments.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...
7
8
    public function getLabelPrefix()
9
    {
10
        return 'Incomplete payments';
11
    }
12
13
    public function getConfiguration()
14
    {
15
        $fields = parent::getConfiguration();
16
17
        return $fields;
18
    }
19
20
    public function Content()
21
    {
22
        $html = '';
23
        $daysBack = $this->calculatedDaysBack();
0 ignored issues
show
Documentation Bug introduced by
The method calculatedDaysBack does not exist on object<EcommerceDashboar...nel_IncompletePayments>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
24
        $data = $this->calculateOnDaysback($daysBack);
25
        $html .= $this->formatContentSection($daysBack, $data);
26
27
        $daysBack = 9999;
28
        $data = $this->calculateOnDaysback($daysBack);
29
        $html .= $this->formatContentSection($daysBack, $data);
30
31
        return $html;
32
33
    }
34
35
    protected function calculateOnDaysback($daysBack)
36
    {
37
        $allPayments = EcommercePayment::get()
38
            ->where('"EcommercePayment"."LastEdited" > ( NOW() - INTERVAL '.($daysBack).' DAY )');
39
        $list = $allPayments->column('Status');
40
        $total = count($list);
41
        $totals = [];
42
        foreach($list as $status) {
43
            if(!isset($totals[$status])) {
44
                $totals[$status] = 0;
45
            }
46
            $totals[$status]++;
47
        }
48
        $data = [
49
            'Total' => $total,
50
            'Totals' => $totals
51
        ];
52
53
        return $data;
54
55
    }
56
57
    protected function formatContentSection($daysBack, $data)
58
    {
59
        if($daysBack > 1000) {
60
            $html = '<h4 style="padding-top: 30px; clear: both;">From the beginning of time:</h4>';
61
        } else {
62
            $html = '<h4>Last '.$daysBack.' days:</h4>';
63
        }
64
        $html .= '<dl>';
65
        foreach($data['Totals'] as $name => $count) {
66
            $percentage = round($count / $data['Total'], 2) * 100;
67
            $html .= '
68
            <dt>'.$name.'</dt>
69
            <dd>'.$count.' × = '.$percentage.'%</dd>';
70
        }
71
72
        return $html;
73
    }
74
75
}
76