Skip to content

Commit

Permalink
Rename PaginationIterator to
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoologic committed Nov 14, 2023
1 parent 25187e2 commit 1e08103
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Zendesk/API/Traits/Utility/Pagination/PaginationIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PaginationIterator implements Iterator
private $strategy;
private $method;
private $position = 0;
private $page = [];
private $items = [];

public function __construct($clientList, AbstractStrategy $strategy, $method = 'findAll')
{
Expand Down Expand Up @@ -48,8 +48,8 @@ public function valid()

public function current()
{
if (isset($this->page[$this->position])) {
return $this->page[$this->position];
if (isset($this->items[$this->position])) {
return $this->items[$this->position];
} else {
return null;
}
Expand All @@ -61,14 +61,14 @@ public function latestResponse()
}
private function getPageIfNeeded()
{
if (isset($this->page[$this->position]) || !$this->strategy->shouldGetPage($this->position)) {
if (isset($this->items[$this->position]) || !$this->strategy->shouldGetPage($this->position)) {
return;
}

$getPageFn = function () {
return $this->clientList->{$this->method}($this->strategy->params());
};

$this->page = array_merge($this->page, $this->strategy->page($getPageFn));
$this->items = array_merge($this->items, $this->strategy->page($getPageFn));
}
}

0 comments on commit 1e08103

Please sign in to comment.