PaginationState
final class PaginationState (View source)
Describes one requested page and derives its offsets, navigation state and page URLs.
Methods
Initializes page boundaries and the URL context preserved across navigation links.
Returns the one-based page selected for this result set.
Returns the number of rows assigned to each page.
Returns the total number of rows in the result set.
Returns the query parameter name that carries the requested page.
Returns the zero-based row offset for the current page.
Returns the highest valid page, with one as the minimum.
Reports whether the result set spans more than one page.
Reports whether a page before the current page exists.
Reports whether a page after the current page exists.
Returns the closest valid page before the current page.
Returns the closest valid page after the current page.
Builds a page URL while retaining non-empty query parameters from this state.
Returns a contiguous window of valid page numbers centered around the current page where possible.
Details
__construct
__construct(int $currentPage, int $perPage, int $total, string $pageName, string $basePath, array $query = [])
Initializes page boundaries and the URL context preserved across navigation links.
currentPage
int
currentPage()
Returns the one-based page selected for this result set.
perPage
int
perPage()
Returns the number of rows assigned to each page.
total
int
total()
Returns the total number of rows in the result set.
pageName
string
pageName()
Returns the query parameter name that carries the requested page.
offset
int
offset()
Returns the zero-based row offset for the current page.
lastPage
int
lastPage()
Returns the highest valid page, with one as the minimum.
hasPages
bool
hasPages()
Reports whether the result set spans more than one page.
hasPrev
bool
hasPrev()
Reports whether a page before the current page exists.
hasNext
bool
hasNext()
Reports whether a page after the current page exists.
prevPage
int
prevPage()
Returns the closest valid page before the current page.
nextPage
int
nextPage()
Returns the closest valid page after the current page.
url
string
url(int $page)
Builds a page URL while retaining non-empty query parameters from this state.
pages
array
pages(int $maxPages = 5)
Returns a contiguous window of valid page numbers centered around the current page where possible.