Completed
Push — master ( f8f77e...d2a4ab )
by Jason
05:01
created

OrderHistoryPage::getOrders()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Dynamic\FoxyStripe\Page;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\ORM\PaginatedList;
7
use SilverStripe\Security\Member;
8
9
class OrderHistoryPage extends \Page
10
{
11
    /**
12
     * @var string
13
     */
14
    private static $singular_name = 'Order History Page';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
15
16
    /**
17
     * @var string
18
     */
19
    private static $plural_name = 'Order History Pages';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
20
21
    /**
22
     * @var string
23
     */
24
    private static $description = 'Show a customers past orders. Requires authentication';
0 ignored issues
show
introduced by
The private property $description is not used, and could be removed.
Loading history...
25
26
    /**
27
     * return all current Member's Orders.
28
     *
29
     * @param int $limit
30
     *
31
     * @return bool|PaginatedList
32
     *
33
     * @throws \Exception
34
     */
35
    public function getOrders($limit = 10)
36
    {
37
        if ($Member = Member::currentUser()) {
0 ignored issues
show
Deprecated Code introduced by
The function SilverStripe\Security\Member::currentUser() has been deprecated: 5.0.0 use Security::getCurrentUser() ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

37
        if ($Member = /** @scrutinizer ignore-deprecated */ Member::currentUser()) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
38
            $Orders = $Member->Orders()->sort('TransactionDate', 'DESC');
39
40
            $list = new PaginatedList($Orders, Controller::curr()->request);
41
            $list->setPageLength($limit);
42
43
            return $list;
44
        }
45
46
        return false;
47
    }
48
}
49