1 | <?php |
||
19 | class Page |
||
20 | { |
||
21 | const DEFAULT_NUMBER_ITEMS = 10; |
||
22 | |||
23 | /** @var HttpRequest */ |
||
24 | private $oHttpRequest; |
||
25 | |||
26 | /** @var int */ |
||
27 | private $iTotalPages; |
||
28 | |||
29 | /** @var int */ |
||
30 | private $iTotalItems; |
||
31 | |||
32 | /** @var int */ |
||
33 | private $iNbItemsPerPage; |
||
34 | |||
35 | /** @var int */ |
||
36 | private $iCurrentPage; |
||
37 | |||
38 | /** @var int */ |
||
39 | private $iFirstItem; |
||
40 | |||
41 | public function __construct() |
||
45 | |||
46 | /** |
||
47 | * @param int $iTotalItems |
||
48 | * @param int $iNbItemsPerPage |
||
49 | * |
||
50 | * @return void |
||
51 | */ |
||
52 | protected function totalPages($iTotalItems, $iNbItemsPerPage) |
||
63 | |||
64 | /** |
||
65 | * @param int $iTotalItems |
||
66 | * @param int $iNbItemsPerPage Default 10 |
||
67 | * |
||
68 | * @return int The number of pages. |
||
69 | */ |
||
70 | public function getTotalPages($iTotalItems, $iNbItemsPerPage = self::DEFAULT_NUMBER_ITEMS) |
||
75 | |||
76 | public function getTotalItems() |
||
80 | |||
81 | public function getFirstItem() |
||
85 | |||
86 | public function getNbItemsPerPage() |
||
90 | |||
91 | public function getCurrentPage() |
||
95 | |||
96 | /** |
||
97 | * Clean a Dynamic URL for some features CMS. |
||
98 | * |
||
99 | * @param string $sVar The Query URL (e.g. www.pierre-henry-soria.com/my-mod/?query=value). |
||
100 | * |
||
101 | * @return string $sPageUrl The new clean URL. |
||
102 | */ |
||
103 | public static function cleanDynamicUrl($sVar) |
||
116 | |||
117 | /** |
||
118 | * Returns a trailing slash if needed. |
||
119 | * |
||
120 | * @param string $sUrl |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | private static function trailingSlash($sUrl) |
||
128 | |||
129 | /** |
||
130 | * @param string $sCurrentUrl |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | private static function getUrlSlug($sCurrentUrl) |
||
138 | } |
||
139 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.