1 | <?php |
||
18 | class Pagination implements \Countable, \IteratorAggregate |
||
19 | { |
||
20 | const DEFAULT_ITEMS_PER_PAGE = 10; |
||
21 | |||
22 | /** @var mixed[] The items */ |
||
23 | private $items; |
||
24 | |||
25 | /** @var int The number of items */ |
||
26 | private $itemsPerPage; |
||
27 | |||
28 | /** |
||
29 | * Construct a pagiantion object with the given items en items per page. |
||
30 | * |
||
31 | * @param mixed[] $items |
||
32 | * @param int $itemsPerPage |
||
33 | */ |
||
34 | 6 | public function __construct(array $items, $itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE) |
|
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | 1 | public function count() |
|
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | 1 | public function getIterator() |
|
55 | |||
56 | /** |
||
57 | * Returns the items on the given page number. |
||
58 | * |
||
59 | * @param int $index |
||
60 | * @return mixed[] the items on the given page number. |
||
61 | */ |
||
62 | 1 | public function get($index) |
|
66 | |||
67 | /** |
||
68 | * Returns an array containing all of the elements in this pagination object. |
||
69 | * |
||
70 | * @return mixed[] an array containing all of the elements in this pagination object. |
||
71 | */ |
||
72 | 1 | public function toArray() |
|
76 | |||
77 | /** |
||
78 | * Returns the items per page. |
||
79 | * |
||
80 | * @return int the items per page. |
||
81 | */ |
||
82 | 2 | public function getItemsPerPage() |
|
86 | |||
87 | /** |
||
88 | * Returns the items per page. |
||
89 | * |
||
90 | * @param $itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE |
||
91 | * @return null |
||
92 | */ |
||
93 | 1 | public function setItemsPerPage($itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE) |
|
97 | } |
||
98 |