PageRequest
in package
One page's worth of `?offset=`/`?limit=`/`?search=` for a paginated §27 list call (CONTRACT.md §27.4 rule 4).
A value object rather than three loose arguments so a caller cannot transpose them at a
call site — new PageRequest(limit: 50) reads what it means, list(50, 0) does not.
Table of Contents
Constants
- DEFAULT_LIMIT : mixed = 50
- The server's own default page size when a call names no limit.
Properties
Methods
- __construct() : mixed
- matching() : self
- This request with `$search` replaced — a COPY, so a shared request cannot be repointed at a different query by unrelated code.
- next() : self
- The page after this one — same size and same term, advanced by exactly this page's `limit`.
- normalizeSearch() : string|null
- The term as it goes on the wire, or `null` when there is nothing to send.
- toQuery() : array<string, int|string>
- The `?offset=`/`?limit=`/`?search=` triple as query parameters.
Constants
DEFAULT_LIMIT
The server's own default page size when a call names no limit.
public
mixed
DEFAULT_LIMIT
= 50
Properties
$limit read-only
public
int
$limit
= self::DEFAULT_LIMIT
$offset read-only
public
int
$offset
= 0
$search read-only
public
string|null
$search
= null
Methods
__construct()
public
__construct([int $offset = 0 ][, int $limit = self::DEFAULT_LIMIT ][, string|null $search = null ]) : mixed
Parameters
- $offset : int = 0
-
How many items to skip; clamped at 0.
- $limit : int = self::DEFAULT_LIMIT
-
How many items to ask for; clamped to at least 1.
- $search : string|null = null
-
A free-text filter applied by the SERVER, before
offset/limit— see self::$search.
matching()
This request with `$search` replaced — a COPY, so a shared request cannot be repointed at a different query by unrelated code.
public
matching(string|null $search) : self
Parameters
- $search : string|null
Return values
selfnext()
The page after this one — same size and same term, advanced by exactly this page's `limit`.
public
next() : self
Advancing by limit rather than by the number of items actually returned is
deliberate: a short page is not proof of the end (§27.4 rule 4 says auto-paging
stops on an EMPTY page, not a short one), and advancing by a short count would
re-request items the caller has already seen.
Carrying $search forward is what makes ManagementTransport::walk() filter
the WHOLE walk rather than only its first request. A walk that dropped the term on
page two would return the matches followed by the unfiltered tail, which reads as a
server bug from the caller's side (§27.4 rule 4).
Return values
selfnormalizeSearch()
The term as it goes on the wire, or `null` when there is nothing to send.
public
static normalizeSearch(string|null $search) : string|null
Trims, then treats a blank result as absent — the same normalisation the server applies. The server's LENGTH cap is deliberately not re-implemented here: a client-side truncation the server would not have made is a silently different query, and the caller would have no way to tell (§27.4 rule 4).
Parameters
- $search : string|null
Return values
string|nulltoQuery()
The `?offset=`/`?limit=`/`?search=` triple as query parameters.
public
toQuery() : array<string, int|string>
search is present only when there is a term to send. §27.4 rule 4 makes absent
and blank the SAME request: a search box that fires on every keystroke sends one
the moment it is cleared, and "rows containing the empty string" is a different
question from "all rows".