class Pager (View source)

A value object that represents a pager.

Properties

protected int $totalItems

The total number of items .

protected int $totalPages

The total number of pages.

protected int $currentPage

The current page of the pager.

protected int $limit

The maximum number of items per page.

Methods

__construct(int $totalItems, int $limit, int $currentPage = 0)

Pager constructor.

setCurrentPage(int $currentPage = 0)

Sets the current page to a valid value within range.

setTotalPages(int $totalItems, int $limit)

Sets the total number of pages.

int
getTotalItems()

Gets the total number of items.

int
getTotalPages()

Gets the total number of pages.

int
getCurrentPage()

Gets the current page.

int
getLimit()

Gets the maximum number of items per page.

Details

__construct(int $totalItems, int $limit, int $currentPage = 0)

Pager constructor.

Parameters

int $totalItems

The total number of items.

int $limit

The maximum number of items per page.

int $currentPage

The current page.

protected setCurrentPage(int $currentPage = 0)

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.

Parameters

int $currentPage

(optional) The current page.

protected setTotalPages(int $totalItems, int $limit)

Sets the total number of pages.

Parameters

int $totalItems

The total number of items.

int $limit

The maximum number of items per page.

int getTotalItems()

Gets the total number of items.

Return Value

int

The total number of items.

int getTotalPages()

Gets the total number of pages.

Return Value

int

The total number of pages.

int getCurrentPage()

Gets the current page.

Return Value

int

The current page.

int getLimit()

Gets the maximum number of items per page.

Return Value

int

The maximum number of items per page.