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.

SecondHandProductValue::group()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
4
class SecondHandProductValue extends SS_Report
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
    /**
7
     * The class of object being managed by this report.
8
     * Set by overriding in your subclass.
9
     */
10
    protected $dataClass = 'SecondHandProduct';
11
12
    /**
13
     * @return string
14
     */
15
    public function title()
16
    {
17
        $values = $this->sourceRecords()->column('PurchasePrice');
18
        $sum = array_sum($values);
19
        $object = Currency::create('Sum');
20
        $object->setValue($sum);
21
        $name = _t(
22
            'EcommerceSideReport.SECOND_HAND_REPORT_TOTAL_STOCK_VALUE',
23
            'Second Hand Products, total stock value'
24
         );
25
        return $name . ': ' . $object->Nice();
26
    }
27
28
    /**
29
     * not sure if this is used in SS3.
30
     *
31
     * @return string
32
     */
33
    public function group()
34
    {
35
        return _t('EcommerceSideReport.ECOMMERCEGROUP', 'Ecommerce');
36
    }
37
38
    /**
39
     * @return int - for sorting reports
40
     */
41
    public function sort()
42
    {
43
        return 8000;
44
    }
45
46
    /**
47
     * working out the items.
48
     *
49
     * @return DataList
50
     */
51
    public function sourceRecords($params = null)
0 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    {
53
        return SecondHandProduct::get()->filter(
54
            array(
55
                'AllowPurchase' => 1,
56
                'SellingOnBehalf' => 0
57
            )
58
        );
59
    }
60
61
    /**
62
     * @return array
63
     */
64
    public function columns()
65
    {
66
        return array(
67
            'InternalItemID' => 'ID',
68
            'Title' => array(
69
                'title' => 'Product Name',
70
                'link' => true,
71
            ),
72
            'Created' => 'Created Time',
73
            'Price' => 'Selling Price',
74
            'PurchasePrice' => 'Purchase Price'
75
        );
76
    }
77
78
    public function getReportField()
79
    {
80
        $field = parent::getReportField();
81
        $config = $field->getConfig();
82
        $exportButton = $config->getComponentByType('GridFieldExportButton');
83
        $exportButton->setExportColumns($field->getColumns());
84
        
85
        return $field;
86
    }
87
}
88