Auth0-PHP

HttpResponsePaginator
in package
implements Countable, Iterator

Class HttpResponsePaginator.

Tags
phpstan-implements

\Iterator<int,mixed>

Interfaces, Classes, Traits and Enums

Countable
Iterator

Table of Contents

SUPPORTED_ENDPOINTS_WITH_CHECKPOINT  = ['^\\/api\\/v2\\/logs$', '^\\/api\\/v2\\/organizations$', '^\\/api\\/v2\\/organizations\\/(.*)\\/members$', '^\\/api\\/v2\\/roles\\/(.*)\\/users$']
These endpoints support checkpoint-based pagination (from, take). A 'next' value will be present in responses if more results are available.
$httpClient  : HttpClient
$nextCheckpoint  : string|null
The 'next' value pulled from checkpoint-paginated results to indicate next page query id.
$position  : int
The current position in use by the Iterator, for tracking our index while looping.
$requestCount  : int
A counter for tracking the number of network requests made for pagination. Does not include any initial network request involved in passing seed data to the class constructor.
$requestLimit  : int
The 'limit' value returned with the last network response.
$requestTotal  : int
The 'total' value returned with the last network response.
$results  : array<string|int, mixed>
A cache of the paginated results. Appended to when new responses are retrieved from the network.
$usingCheckpointPagination  : bool
Whether the requested endpoint we're paginated supports checkpoint-based pagination.
__construct()  : mixed
HttpResponsePaginator constructor.
count()  : int
Return the total number of results available, according to the API.
countNetworkRequests()  : int
Return the total number of network requests made for this paginator instance.
current()  : mixed
Return the current result at our position, if available.
key()  : int
Retrieve the current position, if valid.
next()  : void
Increase our position cursor.
rewind()  : void
Reset position to 0.
valid()  : bool
Return true if a result is available. If a result is not immediately available (cached) but the current position is less than the API-reported total results, a paginated network request will be attempted to get the next results. Returns false when no results are available at the current position.
getNextResults()  : bool
Make a network request for the next page of results.
lastBuilder()  : HttpRequest|null
Return the current instance of the HttpRequest.
lastRequest()  : RequestInterface|null
Return a RequestInterface representing the most recent sent HTTP request.
lastResponse()  : ResponseInterface|null
Return a ResponseInterface representing the most recently returned HTTP response.
processLastResponse()  : bool
Process the previous HttpResponse results and cache them for iterator content.
result()  : array<string|int, mixed>|null
Return the current result at our position, if available.

Constants

SUPPORTED_ENDPOINTS_WITH_CHECKPOINT

These endpoints support checkpoint-based pagination (from, take). A 'next' value will be present in responses if more results are available.

private mixed SUPPORTED_ENDPOINTS_WITH_CHECKPOINT = ['^\\/api\\/v2\\/logs$', '^\\/api\\/v2\\/organizations$', '^\\/api\\/v2\\/organizations\\/(.*)\\/members$', '^\\/api\\/v2\\/roles\\/(.*)\\/users$']

Properties

$nextCheckpoint

The 'next' value pulled from checkpoint-paginated results to indicate next page query id.

private string|null $nextCheckpoint = null

$position

The current position in use by the Iterator, for tracking our index while looping.

private int $position = 0

$requestCount

A counter for tracking the number of network requests made for pagination. Does not include any initial network request involved in passing seed data to the class constructor.

private int $requestCount = 0

$requestLimit

The 'limit' value returned with the last network response.

private int $requestLimit = 0

$requestTotal

The 'total' value returned with the last network response.

private int $requestTotal = 0

$results

A cache of the paginated results. Appended to when new responses are retrieved from the network.

private array<string|int, mixed> $results = []

$usingCheckpointPagination

Whether the requested endpoint we're paginated supports checkpoint-based pagination.

private bool $usingCheckpointPagination = false

Methods

__construct()

HttpResponsePaginator constructor.

public __construct(HttpClient $httpClient) : mixed
Parameters
$httpClient : HttpClient

an instance of HttpClient to use for paginated network requests

Tags
throws
PaginatorException

when an unsupported request type is provided

Return values
mixed

count()

Return the total number of results available, according to the API.

public count() : int
Return values
int

countNetworkRequests()

Return the total number of network requests made for this paginator instance.

public countNetworkRequests() : int
Return values
int

current()

Return the current result at our position, if available.

public current() : mixed
Tags
psalm-suppress

InvalidAttribute

codeCoverageIgnore
Return values
mixed

valid()

Return true if a result is available. If a result is not immediately available (cached) but the current position is less than the API-reported total results, a paginated network request will be attempted to get the next results. Returns false when no results are available at the current position.

public valid() : bool
Return values
bool

getNextResults()

Make a network request for the next page of results.

private getNextResults() : bool
Return values
bool

lastRequest()

Return a RequestInterface representing the most recent sent HTTP request.

private lastRequest() : RequestInterface|null
Return values
RequestInterface|null

lastResponse()

Return a ResponseInterface representing the most recently returned HTTP response.

private lastResponse() : ResponseInterface|null
Return values
ResponseInterface|null

processLastResponse()

Process the previous HttpResponse results and cache them for iterator content.

private processLastResponse() : bool
Return values
bool

result()

Return the current result at our position, if available.

private result() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

Search results