Completed
Push — master ( cf321a...f177e6 )
by Thibaud
07:25
created

OrderList::getTotalCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of alchemy/pipeline-component.
5
 *
6
 * (c) Alchemy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhraseanetSDK\Orders;
13
14
class OrderList 
15
{
16
    /**
17
     * @var \stdClass[]
18
     */
19
    private $source;
20
21
    /**
22
     * @var Order[]|null
23
     */
24
    private $orders;
25
26
    /**
27
     * @var int
28
     */
29
    private $currentPage;
30
31
    /**
32
     * @var int
33
     */
34
    private $totalPages;
35
36
    /**
37
     * @var int
38
     */
39
    private $perPage;
40
41
    /**
42
     * @var int
43
     */
44
    private $count;
45
46
    /**
47
     * @var int
48
     */
49
    private $totalCount;
50
51
    /**
52
     * @param array $source
53
     * @param \stdClass $pagination
54
     */
55
    public function __construct(array $source, \stdClass $pagination)
56
    {
57
        $this->source = $source;
58
        $this->currentPage = (int) $pagination->current_page;
59
        $this->totalPages = (int) $pagination->total_pages;
60
        $this->perPage = (int) $pagination->per_page;
61
        $this->totalCount = (int) $pagination->total;
62
        $this->count = (int) $pagination->count;
63
    }
64
65
    /**
66
     * @return Order[]
67
     */
68
    public function getOrders()
69
    {
70
        return $this->orders ?: $this->orders = Order::fromList($this->source);
71
    }
72
73
    /**
74
     * @return int
75
     */
76
    public function getCurrentPage()
77
    {
78
        return $this->currentPage;
79
    }
80
81
    /**
82
     * @return int
83
     */
84
    public function getTotalPages()
85
    {
86
        return $this->totalPages;
87
    }
88
89
    /**
90
     * @return int
91
     */
92
    public function getPerPage()
93
    {
94
        return $this->perPage;
95
    }
96
97
    /**
98
     * @return int
99
     */
100
    public function getCount()
101
    {
102
        return $this->count;
103
    }
104
105
    /**
106
     * @return int
107
     */
108
    public function getTotalCount()
109
    {
110
        return $this->totalCount;
111
    }
112
}
113