\CKPageCalc

A class to calculate page numbers and cursors of paged results

Summary

Methods
Properties
Constants
__construct()
moveCursor()
gotoPage()
getCursor()
getNextCursor()
getPreviousCursor()
getLastCursor()
getTotalPages()
getPage()
getLastPage()
getNextPage()
getPreviousPage()
No public properties found
No constants found
No protected methods found
$limit
$cursor
$page
N/A
No private methods found
No private properties found
N/A

Properties

$limit

$limit : integer

Type

integer — Number of items on one page

$cursor

$cursor : integer

Type

integer — Number of the first item on the current page

$page

$page : integer

Type

integer — Number of the current page

Methods

__construct()

__construct(integer  $limit) 

Construct and set defaults

Parameters

integer $limit

Number of items on one page

Throws

\UnexpectedValueException

if limit is not higher than zero

moveCursor()

moveCursor(integer  $cursor, integer  $limit = false) 

Set current cursor and update current page

Parameters

integer $cursor

number of the first item

integer $limit

number of items on one page is optional

Throws

\UnexpectedValueException

if value of parameter cursor makes pagination invalid

gotoPage()

gotoPage(integer  $page, integer  $limit = false) 

Set current page and update current cursor

Parameters

integer $page

current page number

integer $limit

number of items on one page is optional

getCursor()

getCursor() : integer

Get number of current cursor

Returns

integer —

number of current cursor

getNextCursor()

getNextCursor(integer  $total) : integer|boolean

Get number of next cursor

Parameters

integer $total

Total number of items

Returns

integer|boolean —

number of next cursor or false if not applicable

getPreviousCursor()

getPreviousCursor() : integer|boolean

Get number of previous cursor

Returns

integer|boolean —

number of previous cursor or false if not applicable

getLastCursor()

getLastCursor(integer  $total) : integer

Get number of last cursor

Parameters

integer $total

total number of items

Returns

integer —

number of last cursor

getTotalPages()

getTotalPages(integer  $total) 

Get total number of pages

Parameters

integer $total

total number of items

getPage()

getPage() : integer

Get number of current page

Returns

integer —

number of current page

getLastPage()

getLastPage(integer  $total) : integer

Get number of last page

Parameters

integer $total

total number of items

Returns

integer —

total number of pages

getNextPage()

getNextPage(integer  $total) : integer|boolean

Get number of next page

Parameters

integer $total

total number of items

Returns

integer|boolean —

number of next page or false if no applicable

getPreviousPage()

getPreviousPage() : integer|boolean

Get the previous page

Returns

integer|boolean —

number of previous page or false if no applicable