@@ -17,81 +17,81 @@ |
||
17 | 17 | */ |
18 | 18 | class Pagination implements \Countable, \IteratorAggregate |
19 | 19 | { |
20 | - const DEFAULT_ITEMS_PER_PAGE = 10; |
|
20 | + const DEFAULT_ITEMS_PER_PAGE = 10; |
|
21 | 21 | |
22 | - /** @var mixed[] The items */ |
|
23 | - private $items; |
|
22 | + /** @var mixed[] The items */ |
|
23 | + private $items; |
|
24 | 24 | |
25 | - /** @var int The number of items */ |
|
26 | - private $itemsPerPage; |
|
25 | + /** @var int The number of items */ |
|
26 | + private $itemsPerPage; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Construct a pagination object with the given items en items per page. |
|
30 | - * |
|
31 | - * @param mixed[] $items |
|
32 | - * @param int $itemsPerPage |
|
33 | - */ |
|
34 | - public function __construct(array $items, $itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE) |
|
35 | - { |
|
36 | - $this->items = $items; |
|
37 | - $this->itemsPerPage = $itemsPerPage; |
|
38 | - } |
|
28 | + /** |
|
29 | + * Construct a pagination object with the given items en items per page. |
|
30 | + * |
|
31 | + * @param mixed[] $items |
|
32 | + * @param int $itemsPerPage |
|
33 | + */ |
|
34 | + public function __construct(array $items, $itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE) |
|
35 | + { |
|
36 | + $this->items = $items; |
|
37 | + $this->itemsPerPage = $itemsPerPage; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * {@inheritdoc} |
|
42 | - */ |
|
43 | - public function count() |
|
44 | - { |
|
45 | - return ceil(count($this->items) / $this->itemsPerPage); |
|
46 | - } |
|
40 | + /** |
|
41 | + * {@inheritdoc} |
|
42 | + */ |
|
43 | + public function count() |
|
44 | + { |
|
45 | + return ceil(count($this->items) / $this->itemsPerPage); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * {@inheritdoc} |
|
50 | - */ |
|
51 | - public function getIterator() |
|
52 | - { |
|
53 | - return new \ArrayIterator(array_chunk($this->items, $this->itemsPerPage)); |
|
54 | - } |
|
48 | + /** |
|
49 | + * {@inheritdoc} |
|
50 | + */ |
|
51 | + public function getIterator() |
|
52 | + { |
|
53 | + return new \ArrayIterator(array_chunk($this->items, $this->itemsPerPage)); |
|
54 | + } |
|
55 | 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 | - public function get($index) |
|
63 | - { |
|
64 | - return array_slice($this->items, $index * $this->itemsPerPage, $this->itemsPerPage); |
|
65 | - } |
|
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 | + public function get($index) |
|
63 | + { |
|
64 | + return array_slice($this->items, $index * $this->itemsPerPage, $this->itemsPerPage); |
|
65 | + } |
|
66 | 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 | - public function toArray() |
|
73 | - { |
|
74 | - return $this->items; |
|
75 | - } |
|
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 | + public function toArray() |
|
73 | + { |
|
74 | + return $this->items; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Returns the items per page. |
|
79 | - * |
|
80 | - * @return int the items per page. |
|
81 | - */ |
|
82 | - public function getItemsPerPage() |
|
83 | - { |
|
84 | - return $this->itemsPerPage; |
|
85 | - } |
|
77 | + /** |
|
78 | + * Returns the items per page. |
|
79 | + * |
|
80 | + * @return int the items per page. |
|
81 | + */ |
|
82 | + public function getItemsPerPage() |
|
83 | + { |
|
84 | + return $this->itemsPerPage; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Returns the items per page. |
|
89 | - * |
|
90 | - * @param $itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE |
|
91 | - * @return null |
|
92 | - */ |
|
93 | - public function setItemsPerPage($itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE) |
|
94 | - { |
|
95 | - $this->itemsPerPage = $itemsPerPage; |
|
96 | - } |
|
87 | + /** |
|
88 | + * Returns the items per page. |
|
89 | + * |
|
90 | + * @param $itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE |
|
91 | + * @return null |
|
92 | + */ |
|
93 | + public function setItemsPerPage($itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE) |
|
94 | + { |
|
95 | + $this->itemsPerPage = $itemsPerPage; |
|
96 | + } |
|
97 | 97 | } |