OrderHistoryPage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 1
b 0
f 0
dl 0
loc 38
ccs 0
cts 7
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOrders() 0 12 2
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
use SilverStripe\Security\Security;
9
10
class OrderHistoryPage extends \Page
11
{
12
    /**
13
     * @var string
14
     */
15
    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...
16
17
    /**
18
     * @var string
19
     */
20
    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...
21
22
    /**
23
     * @var string
24
     */
25
    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...
26
27
    /**
28
     * return all current Member's Orders.
29
     *
30
     * @param int $limit
31
     *
32
     * @return bool|PaginatedList
33
     *
34
     * @throws \Exception
35
     */
36
    public function getOrders($limit = 10)
37
    {
38
        if ($Member = Security::getCurrentUser()) {
39
            $Orders = $Member->Orders()->sort('TransactionDate', 'DESC');
40
41
            $list = new PaginatedList($Orders, Controller::curr()->getRequest());
42
            $list->setPageLength($limit);
43
44
            return $list;
45
        }
46
47
        return false;
48
    }
49
}
50