Paginator
in package
implements
IteratorAggregate, Countable
FinalYes
Paginator that allows to iterate over all pages.
Tags
Table of Contents
Interfaces
- IteratorAggregate
- Countable
Properties
- $collection : array<int, TItem>
- $counter : Closure|null
- $loader : Generator
- $nextPage : self|null
- $pageNumber : int
- $totalItems : int|null
Methods
- count() : int
- Value is cached in all produced pages after first call in any page.
- getIterator() : Traversable<string|int, TItem>
- Iterate all items from current page and all next pages.
- getNextPage() : self|null
- Load next page.
- getPageItems() : array<string|int, TItem>
- getPageNumber() : int<1, max>
- __construct() : mixed
Properties
$collection
private
array<int, TItem>
$collection
$counter
private
Closure|null
$counter
$loader read-only
private
Generator
$loader
$nextPage
private
self|null
$nextPage
= null
$pageNumber read-only
private
int
$pageNumber
$totalItems
private
int|null
$totalItems
= null
Methods
count()
Value is cached in all produced pages after first call in any page.
public
count() : int
Note: the method may call yet another RPC to get total number of items. It means that the result may be different from the number of items at the moment of the pagination start.
Tags
Return values
intgetIterator()
Iterate all items from current page and all next pages.
public
getIterator() : Traversable<string|int, TItem>
Return values
Traversable<string|int, TItem>getNextPage()
Load next page.
public
getNextPage() : self|null
Return values
self|nullgetPageItems()
public
getPageItems() : array<string|int, TItem>
Return values
array<string|int, TItem>getPageNumber()
public
getPageNumber() : int<1, max>
Return values
int<1, max>__construct()
private
__construct(Generator<string|int, array<int, TItem>> $loader, int<1, max> $pageNumber, null|callable(): int<0, max> $counter) : mixed
Parameters
- $loader : Generator<string|int, array<int, TItem>>
- $pageNumber : int<1, max>
- $counter : null|callable(): int<0, max>