Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
1 / 1 |
| PaginationView | |
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
8 | |
100.00% |
1 / 1 |
| getMaxPages | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setMaxPages | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPages | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setPages | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setPage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getResults | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setResults | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package phpOMS\Views |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace phpOMS\Views; |
| 16 | |
| 17 | /** |
| 18 | * Pagination view. |
| 19 | * |
| 20 | * @package phpOMS\Views |
| 21 | * @license OMS License 2.0 |
| 22 | * @link https://jingga.app |
| 23 | * @since 1.0.0 |
| 24 | */ |
| 25 | class PaginationView extends View |
| 26 | { |
| 27 | /** |
| 28 | * Maximum amount of pages. |
| 29 | * |
| 30 | * @var int |
| 31 | * @since 1.0.0 |
| 32 | */ |
| 33 | protected int $maxPages = 7; |
| 34 | |
| 35 | /** |
| 36 | * Current page id. |
| 37 | * |
| 38 | * @var int |
| 39 | * @since 1.0.0 |
| 40 | */ |
| 41 | protected int $page = 1; |
| 42 | |
| 43 | /** |
| 44 | * How many pages exist? |
| 45 | * |
| 46 | * @var int |
| 47 | * @since 1.0.0 |
| 48 | */ |
| 49 | protected int $pages = 1; |
| 50 | |
| 51 | /** |
| 52 | * How many results exist? |
| 53 | * |
| 54 | * @var int |
| 55 | * @since 1.0.0 |
| 56 | */ |
| 57 | protected int $results = 0; |
| 58 | |
| 59 | /** |
| 60 | * @return int |
| 61 | * |
| 62 | * @since 1.0.0 |
| 63 | */ |
| 64 | public function getMaxPages() : int |
| 65 | { |
| 66 | return $this->maxPages; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * @param int $maxPages Maximum amount of pages to be shown |
| 71 | * |
| 72 | * @return void |
| 73 | * |
| 74 | * @since 1.0.0 |
| 75 | */ |
| 76 | public function setMaxPages(int $maxPages) : void |
| 77 | { |
| 78 | $this->maxPages = $maxPages; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return int |
| 83 | * |
| 84 | * @since 1.0.0 |
| 85 | */ |
| 86 | public function getPages() : int |
| 87 | { |
| 88 | return $this->pages; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @param int $pages Number of pages |
| 93 | * |
| 94 | * @return void |
| 95 | * |
| 96 | * @since 1.0.0 |
| 97 | */ |
| 98 | public function setPages(int $pages) : void |
| 99 | { |
| 100 | $this->pages = $pages; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * @return int |
| 105 | * |
| 106 | * @since 1.0.0 |
| 107 | */ |
| 108 | public function getPage() : int |
| 109 | { |
| 110 | return $this->page; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @param int $page Current page index |
| 115 | * |
| 116 | * @return void |
| 117 | * |
| 118 | * @since 1.0.0 |
| 119 | */ |
| 120 | public function setPage(int $page = 1) : void |
| 121 | { |
| 122 | $this->page = $page; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * @return int |
| 127 | * |
| 128 | * @since 1.0.0 |
| 129 | */ |
| 130 | public function getResults() : int |
| 131 | { |
| 132 | return $this->results; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * @param int $results Amount of results |
| 137 | * |
| 138 | * @return void |
| 139 | * |
| 140 | * @since 1.0.0 |
| 141 | */ |
| 142 | public function setResults(int $results = 0) : void |
| 143 | { |
| 144 | $this->results = $results; |
| 145 | } |
| 146 | } |