class Page implements IteratorAggregate

A Page object wraps an API list method response and provides methods to retrieve additional pages using the page token.

Constants

FINAL_PAGE_TOKEN

Methods

__construct(Call $call, array $options, callable $callable, PageStreamingDescriptor $pageStreamingDescriptor, Message $response)

Page constructor.

bool
hasNextPage()

Returns true if there are more pages that can be retrieved from the API.

string
getNextPageToken()

Returns the next page token from the response.

getNextPage(int|null $pageSize = null)

Retrieves the next Page object using the next page token.

int
getPageElementCount()

Return the number of elements in the response.

getIterator()

Return an iterator over the elements in the response.

Page[]
iteratePages()

Return an iterator over Page objects, beginning with this object.

Message
getRequestObject()

Gets the request object used to generate the Page.

Message
getResponseObject()

Gets the API response object.

expandToFixedSizeCollection($collectionSize)

Returns a collection of elements with a fixed size set by the collectionSize parameter. The collection will only contain fewer than collectionSize elements if there are no more pages to be retrieved from the server.

Details

at line 64
__construct(Call $call, array $options, callable $callable, PageStreamingDescriptor $pageStreamingDescriptor, Message $response)

Page constructor.

Parameters

Call $call
array $options
callable $callable
PageStreamingDescriptor $pageStreamingDescriptor
Message $response

at line 87
bool hasNextPage()

Returns true if there are more pages that can be retrieved from the API.

Return Value

bool

at line 97
string getNextPageToken()

Returns the next page token from the response.

Return Value

string

at line 111
Page getNextPage(int|null $pageSize = null)

Retrieves the next Page object using the next page token.

Parameters

int|null $pageSize

Return Value

Page

Exceptions

ValidationException if there are no pages remaining, or if pageSize is supplied but is not supported by the API

at line 157
int getPageElementCount()

Return the number of elements in the response.

Return Value

int

at line 168
Generator getIterator()

Return an iterator over the elements in the response.

Return Value

Generator

at line 183
Page[] iteratePages()

Return an iterator over Page objects, beginning with this object.

Additional Page objects are retrieved lazily via API calls until all elements have been retrieved.

Return Value

Page[]

at line 198
Message getRequestObject()

Gets the request object used to generate the Page.

Return Value

Message

at line 208
Message getResponseObject()

Gets the API response object.

Return Value

Message

at line 229
FixedSizeCollection expandToFixedSizeCollection($collectionSize)

Returns a collection of elements with a fixed size set by the collectionSize parameter. The collection will only contain fewer than collectionSize elements if there are no more pages to be retrieved from the server.

NOTE: it is an error to call this method if an optional parameter to set the page size is not supported or has not been set in the API call that was used to create this page. It is also an error if the collectionSize parameter is less than the page size that has been set.

Parameters

$collectionSize int

Return Value

FixedSizeCollection

Exceptions

ValidationException if a FixedSizeCollection of the specified size cannot be constructed