# Class PaginatedIterator

Class ResourceIterator is tasked with iterating over resource collections - many of which are paginated. Based on a base URL, the iterator will append elements based on further requests to the API. Each time this happens, query parameters (marker) are updated based on the current value.

  OpenCloud\Common\ArrayAccess implements ArrayAccess
  OpenCloud\Common\Collection\ArrayCollection implements Countable
  OpenCloud\Common\Collection\ResourceIterator implements Iterator
  OpenCloud\Common\Collection\PaginatedIterator implements Iterator

#### Direct known subclasses

OpenCloud\DNS\Collection\DnsIterator
Namespace: OpenCloud\Common\Collection
Package: OpenCloud\Common\Collection
Since: 1.8.0
Located at OpenCloud/Common/Collection/PaginatedIterator.php

Methods summary
`public static static` | # `factory( mixed $parent, array $options = array(), array $data = null )` Basic factory method to easily instantiate a new ResourceIterator. Basic factory method to easily instantiate a new ResourceIterator. #### Parameters $parent `mixed` $parent The parent object $options `array` $options Iterator options $data `array` $data Optional data to set initially #### Returns `static` #### Overrides `OpenCloud\Common\Collection\ResourceIterator::factory()`
`public mixed` | # `setBaseUrl( Guzzle\Http\Url $url )` #### Parameters $url `Guzzle\Http\Url` $url #### Returns `mixed` $this
`public mixed` | # `current( )` #### Returns `mixed` #### Overrides `OpenCloud\Common\Collection\ResourceIterator::current()` #### Implementation of `Iterator::current()`
`public integer|mixed` | # `key( )` Return the current position/internal pointer. Return the current position/internal pointer. #### Returns `integer|mixed` #### Overrides `OpenCloud\Common\Collection\ResourceIterator::key()` #### Implementation of `Iterator::key()`
`public` | # `next( )` Increment the current pointer by 1, and also update the current marker. Also update the current marker. Increment the current pointer by 1, and also update the current marker. Also update the current marker. #### Overrides `OpenCloud\Common\Collection\ResourceIterator::next()` #### Implementation of `Iterator::next()`
`public` | # `updateMarkerToCurrent( )` Update the current marker based on the current element. The marker will be based on a particular property of this current element, so you must retrieve it first. Update the current marker based on the current element. The marker will be based on a particular property of this current element, so you must retrieve it first.
`public` | # `rewind( )` Reset the pointer and current marker. Also reset current marker. Reset the pointer and current marker. Also reset current marker. #### Overrides `OpenCloud\Common\Collection\ResourceIterator::rewind()` #### Implementation of `Iterator::rewind()`
`public boolean` | # `valid( )` This method is called after self::rewind() and self::next() to check if the current position is valid. This method is called after self::rewind() and self::next() to check if the current position is valid. #### Returns `boolean` #### Overrides `OpenCloud\Common\Collection\ResourceIterator::valid()` #### Implementation of `Iterator::valid()`
`protected` | # `shouldAppend( )`
`public mixed` | # `appendElements( array $elements )` Append an array of standard objects to the current collection. Append an array of standard objects to the current collection. #### Parameters $elements `array` $elements #### Returns `mixed` $this
`public mixed` | # `appendNewCollection( )` Retrieve a new page of elements from the API (based on a new request), parse its response, and append them to the collection. Retrieve a new page of elements from the API (based on a new request), parse its response, and append them to the collection. #### Returns `mixed` $this|bool
`public boolean` | # `extractNextLink( mixed $body )` Based on the response body, extract the explicitly set "link" value if provided. Based on the response body, extract the explicitly set "link" value if provided. #### Parameters $body `mixed` $body #### Returns `boolean`
`public Guzzle\Http\Url|string` | # `constructNextUrl( )` Make the next page URL. Make the next page URL. #### Returns `Guzzle\Http\Url|string`
`public array` | # `parseResponseBody( mixed $body )` Based on the response from the API, parse it for the data we need (i.e. an meaningful array of elements). Based on the response from the API, parse it for the data we need (i.e. an meaningful array of elements). #### Parameters $body `mixed` $body #### Returns `array`
`public` | # `populateAll( )` Walk the entire collection, populating everything. Walk the entire collection, populating everything.

Methods inherited from OpenCloud\Common\Collection\ResourceIterator
`constructResource(), currentElement(), getElement(), getOption(), getOptions(), parseOptions(), search(), setOption(), setOptions(), setResourceParent(), sort()`

Methods inherited from OpenCloud\Common\Collection\ArrayCollection
`__construct(), append(), count(), setElements(), valueExists()`

Methods inherited from OpenCloud\Common\ArrayAccess
`offsetExists(), offsetGet(), offsetSet(), offsetUnset()`

Constants summary
`string` | `MARKER` | `'marker'` | #
`string` | `LIMIT` | `'limit'` | #

Properties summary
`protected string` | $currentMarker | `` | # Used for requests which append elements. Used for requests which append elements.
`protected Guzzle\Http\Url` | $nextUrl | `` | # The next URL for pagination The next URL for pagination
`protected array` | $defaults | `array( // Collection limits 'limit.total' => 10000, 'limit.page' => 100, // The "links" element key in response 'key.links' => 'links', // JSON structure 'key.collection' => null, 'key.collectionElement' => null, // The property used as the marker 'key.marker' => 'name', // Options for "next page" request 'request.method' => 'GET', 'request.headers' => array(), 'request.body' => null, 'request.curlOptions' => array() )` | # Fallback defaults if options are not explicitly set or provided. Fallback defaults if options are not explicitly set or provided.
`protected array` | $required | `array('resourceClass', 'baseUrl')` | # Required options Required options

Properties inherited from OpenCloud\Common\Collection\ResourceIterator
`$options, $position, $resourceParent`

Properties inherited from OpenCloud\Common\Collection\ArrayCollection
`$elements`