abstract class CursorPaginator extends Paginator

Properties

protected int $pageNumber

The page number applied to the next request.

from  Paginator
protected int $currentPage

The zero-based iterator position.

from  Paginator
protected int $startPage

The first page number requested after rewind.

from  Paginator
protected int|null $maxPages

The optional maximum number of pages to request.

from  Paginator
protected int|null $perPageLimit

The optional result limit per page.

from  Paginator
protected null|Response<mixed> $currentResponse

The current response.

from  Paginator
protected bool $currentPageLoaded

Whether the current page has been fetched and mapped.

from  Paginator
protected TItem> $currentPageItems

The items mapped from the final current response.

from  Paginator
protected int $totalResults

The total number of mapped results processed.

from  Paginator
protected bool $detectInfiniteLoop

Whether repeated response bodies should stop iteration.

from  Paginator
protected bool $checksumIncludesContinuation

Whether page checksums include the provider's continuation, so a repeated checksum repeats an earlier request.

protected bool $pooling

Whether the paginator is currently preparing pooled pages.

from  Paginator
protected array<int, string> $lastFiveBodyChecksums

The latest response checksums, including continuation where available.

from  Paginator
protected string $cursorName

The cursor query parameter.

protected string $perPageName

The per-page limit query parameter.

Methods

__construct(Connector $connector, Request $request)

Create a paginator.

current()

Get the response for the current page.

void
next()

Move to the next page.

int
key()

Get the current iterator key.

bool
valid()

Determine if another page should be requested.

void
rewind()

Reset all iterator state.

void
onRewind()

Process extra state when the paginator rewinds.

iterable
items()

Iterate over every response item.

collect(bool $throughItems = true)

Create a lazy collection from page responses or response items.

array
pool(int $concurrency = 5, callable|null $responseHandler = null, callable|null $exceptionHandler = null)

Reject pooled cursor pagination because later cursors depend on earlier responses.

int
totalResults()

Get the total number of processed results.

maxPages(int|null $maxPages)

Set the maximum number of pages to request.

perPageLimit(int|null $perPageLimit)

Set the number of results requested per page.

request()

Get the cloned request used by this paginator.

int
currentPage()

Get the current zero-based page position.

startPage(int $startPage)

Set the first page number requested after rewind.

int
count()

Count the number of pages yielded by the iterator.

string
getPageChecksum(Response $response)

Compare page contents together with the provider's continuation cursor.

string
getBodyChecksum(Response $response)

Get the checksum of the response body.

array
pageItems(Response $response)

Resolve response items using the request override when present.

iterable
remainingRequests(int $lastPage)

Yield independently addressable page requests after the first page.

int
getTotalPages(Response $response)

Get the total number of independently addressable pages.

applyPagination(Request $request)

Apply cursor pagination to the request.

bool
isLastPage(Response $response)

Determine if the response is the last page.

array
getPageItems(Response $response, Request $request)

Get the items from one page.

bool|float|int|string|null
getNextCursor(Response $response)

Get the next cursor.

Details

in Paginator at line 105
__construct(Connector $connector, Request $request)

Create a paginator.

Parameters

Connector $connector
Request $request

in Paginator at line 126
Response current()

Get the response for the current page.

Return Value

Response

in Paginator at line 179
void next()

Move to the next page.

Return Value

void

in Paginator at line 190
int key()

Get the current iterator key.

Return Value

int

in Paginator at line 198
bool valid()

Determine if another page should be requested.

Return Value

bool

in Paginator at line 210
void rewind()

Reset all iterator state.

Return Value

void

in Paginator at line 225
protected void onRewind()

Process extra state when the paginator rewinds.

Return Value

void

in Paginator at line 234
iterable items()

Iterate over every response item.

Return Value

iterable

in Paginator at line 248
LazyCollection collect(bool $throughItems = true)

Create a lazy collection from page responses or response items.

Parameters

bool $throughItems

Return Value

LazyCollection

at line 86
array pool(int $concurrency = 5, callable|null $responseHandler = null, callable|null $exceptionHandler = null)

Reject pooled cursor pagination because later cursors depend on earlier responses.

Parameters

int $concurrency
callable|null $responseHandler
callable|null $exceptionHandler

Return Value

array

in Paginator at line 341
int totalResults()

Get the total number of processed results.

Return Value

int

in Paginator at line 351
Paginator maxPages(int|null $maxPages)

Set the maximum number of pages to request.

Parameters

int|null $maxPages

Return Value

Paginator

in Paginator at line 363
Paginator perPageLimit(int|null $perPageLimit)

Set the number of results requested per page.

Parameters

int|null $perPageLimit

Return Value

Paginator

in Paginator at line 375
Request request()

Get the cloned request used by this paginator.

Return Value

Request

in Paginator at line 383
int currentPage()

Get the current zero-based page position.

Return Value

int

in Paginator at line 393
Paginator startPage(int $startPage)

Set the first page number requested after rewind.

Parameters

int $startPage

Return Value

Paginator

in Paginator at line 403
int count()

Count the number of pages yielded by the iterator.

Return Value

int

at line 58
protected string getPageChecksum(Response $response)

Compare page contents together with the provider's continuation cursor.

Parameters

Response $response

Return Value

string

in Paginator at line 431
protected string getBodyChecksum(Response $response)

Get the checksum of the response body.

Parameters

Response $response

Return Value

string

in Paginator at line 442
protected array pageItems(Response $response)

Resolve response items using the request override when present.

Parameters

Response $response

Return Value

array

in Paginator at line 459
protected iterable remainingRequests(int $lastPage)

Yield independently addressable page requests after the first page.

Parameters

int $lastPage

Return Value

iterable

in Paginator at line 474
protected int getTotalPages(Response $response)

Get the total number of independently addressable pages.

Parameters

Response $response

Return Value

int

at line 40
protected Request applyPagination(Request $request)

Apply cursor pagination to the request.

Parameters

Request $request

Return Value

Request

in Paginator at line 492
abstract protected bool isLastPage(Response $response)

Determine if the response is the last page.

Parameters

Response $response

Return Value

bool

in Paginator at line 501
abstract protected array getPageItems(Response $response, Request $request)

Get the items from one page.

Parameters

Response $response
Request $request

Return Value

array

at line 77
abstract protected bool|float|int|string|null getNextCursor(Response $response)

Get the next cursor.

The default query encoding omits null and encodes booleans as 1/0; override applyPagination() when the API requires another encoding.

Parameters

Response $response

Return Value

bool|float|int|string|null