/**
* Sets the current page to a valid value within range.
*
* If a page that does not correspond to the actual range of the result set
* was provided, this function will set the closest page actually within
* the result set.
*
* @param int $currentPage
* (optional) The current page.
*/
protected function setCurrentPage($currentPage = 0
) { $this->currentPage =
max(0,
min($currentPage,
$this->
getTotalPages() - 1
));
} /**
* Sets the total number of pages.
*
* @param int $totalItems
* The total number of items.
* @param int $limit
* The maximum number of items per page.
*/
protected function setTotalPages($totalItems,
$limit) {