PaginatorInterface

An interface that defines methods needed to implement a paginator, i.e. an object that handles a set of items and returns a sub set of items, given by a configuration.

Table of Contents

Methods

getCurrentPageNumber()  : int
Returns the current page number
getKeyOfFirstPaginatedItem()  : int
Returns the key of the first paginated item
getKeyOfLastPaginatedItem()  : int
Returns the key of the last paginated item
getNumberOfPages()  : int
Returns the total number of pages, given the total number of non paginated items and the items per page configuration
getPaginatedItems()  : iterable<string|int, mixed>
Returns an iterable, sub set of the original set of items
withCurrentPageNumber()  : PaginatorInterface
Sets the current page to calculate paginated items for
withItemsPerPage()  : PaginatorInterface
Sets the amount of paginated items per page

Methods

getCurrentPageNumber()

Returns the current page number

public getCurrentPageNumber() : int
Return values
int

getKeyOfFirstPaginatedItem()

Returns the key of the first paginated item

public getKeyOfFirstPaginatedItem() : int

This is useful to display the exact range of items that are available via getPaginatedItems

Return values
int

getKeyOfLastPaginatedItem()

Returns the key of the last paginated item

public getKeyOfLastPaginatedItem() : int

This is useful to display the exact range of items that are available via getPaginatedItems

Return values
int

getNumberOfPages()

Returns the total number of pages, given the total number of non paginated items and the items per page configuration

public getNumberOfPages() : int
Return values
int

getPaginatedItems()

Returns an iterable, sub set of the original set of items

public getPaginatedItems() : iterable<string|int, mixed>
Return values
iterable<string|int, mixed>

withCurrentPageNumber()

Sets the current page to calculate paginated items for

public withCurrentPageNumber(int $currentPageNumber) : PaginatorInterface

Must return a new instance of the Paginator with an updated internal state

Parameters
$currentPageNumber : int
Return values
PaginatorInterface

withItemsPerPage()

Sets the amount of paginated items per page

public withItemsPerPage(int $itemsPerPage) : PaginatorInterface

Must return a new instance of the Paginator with an updated internal state

Parameters
$itemsPerPage : int
Return values
PaginatorInterface

        
On this page

Search results