api = $api; $this->data = (array) $api->export(); } /** * Get the current key * * @return int|string */ function key() { return $this->key; } /** * Get the current data entry * * @return API */ function current() { return $this->cur; } function next() { if (list($key, $cur) = each($this->data)) { $this->key = $key; if ($this->api->$key->exists("url", $url)) { $url = new Url($url); $this->cur = $this->api->withUrl($url)->withData($cur); } else { $this->cur = $this->api->$key->withData($cur); } } else { $this->key = null; $this->cur = null; } } function valid() { return isset($this->cur); } function rewind() { if (is_array($this->data)) { reset($this->data); $this->next(); } } }