47 'resource_iterator.before_send',
49 'resource_iterator.after_send'
67 $this->limit = array_key_exists(
'limit',
$data) ?
$data[
'limit'] : 0;
68 $this->pageSize = array_key_exists(
'page_size',
$data) ?
$data[
'page_size'] :
false;
78 return iterator_to_array($this,
false);
104 public function get($key)
106 return array_key_exists($key, $this->data) ? $this->data[$key] :
null;
117 public function set($key, $value)
119 $this->data[$key] = $value;
126 return $this->resources ?
current($this->resources) :
false;
129 public function key()
131 return max(0, $this->iteratedCount - 1);
134 public function count()
160 public function valid()
163 && (!$this->limit || $this->iteratedCount < $this->limit + 1);
166 public function next()
168 $this->iteratedCount++;
171 $sendRequest =
false;
172 if (!$this->resources) {
176 $current =
next($this->resources);
177 $sendRequest = $current ===
false && $this->nextToken && (!$this->limit || $this->iteratedCount < $this->limit + 1);
182 $this->
dispatch(
'resource_iterator.before_send', array(
184 'resources' => $this->resources
191 $this->requestCount++;
195 if (empty($this->resources)) {
196 $this->invalid =
true;
199 $this->retrievedCount +=
count($this->resources);
201 reset($this->resources);
204 $this->
dispatch(
'resource_iterator.after_send', array(
206 'resources' => $this->resources
229 if ($this->limit && $this->iteratedCount + $this->pageSize > $this->limit) {
241 $this->iteratedCount = 0;
242 $this->retrievedCount = 0;
243 $this->nextToken =
false;
244 $this->resources =
null;
245 $this->invalid =
false;