Page
in package
implements
IteratorAggregate, Countable
One page of a paginated §27 list response (CONTRACT.md §27.4 rule 4).
$total is the server's count of everything matching the query, NOT
count($this->items). Confusing the two is the single most common way a management
client silently processes only the first fifty of four hundred objects, so this class
keeps them as separate, separately-named properties and never derives one from the
other.
A bare JSON array response is NOT a page and is never modelled as one (§27.4 rule 4);
the generated surface returns those as a plain list<T>.
Tags
Table of Contents
Interfaces
- IteratorAggregate
- Countable
Properties
- $items : array<string|int, mixed>
- $request : PageRequest
- $total : int
Methods
- __construct() : mixed
- count() : int
- How many items are on THIS page. Deliberately not `$total`: `count($page)` must agree with what iterating the page yields, or the two disagree silently.
- getIterator() : ArrayIterator<int, T>
- The items on this page — iterate the page directly and you get these.
- isEmpty() : bool
- True when this page carried nothing. §27.4 rule 4 makes THIS, not a short page, the auto-paging stop condition.
- nextRequest() : PageRequest
- The request that would fetch the page after this one.
Properties
$items read-only
public
array<string|int, mixed>
$items
$request read-only
public
PageRequest
$request
$total read-only
public
int
$total
Methods
__construct()
public
__construct(array<int, T> $items, int $total, PageRequest $request) : mixed
Parameters
- $items : array<int, T>
-
The items on THIS page.
- $total : int
-
The server's total across all pages.
- $request : PageRequest
-
The request that produced this page, so self::nextRequest() can continue from it.
count()
How many items are on THIS page. Deliberately not `$total`: `count($page)` must agree with what iterating the page yields, or the two disagree silently.
public
count() : int
Return values
intgetIterator()
The items on this page — iterate the page directly and you get these.
public
getIterator() : ArrayIterator<int, T>
Return values
ArrayIterator<int, T>isEmpty()
True when this page carried nothing. §27.4 rule 4 makes THIS, not a short page, the auto-paging stop condition.
public
isEmpty() : bool
Return values
boolnextRequest()
The request that would fetch the page after this one.
public
nextRequest() : PageRequest
Carries this page's search term forward with it (§27.4 rule 4) — that is
PageRequest::next()'s job, not this one's, so every walk built on
nextRequest() filters the whole walk rather than only its first request.