Navigation Menu

Skip to content

Commit

Permalink
Added tests and fixed a bug in BufferedIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Sep 21, 2014
1 parent 0832a0d commit e7f2d27
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Collection/Iterator/BufferedIterator.php
Expand Up @@ -59,6 +59,13 @@ class BufferedIterator extends Collection {
*/
protected $_started = false;

/**
* Whether or not the internal iterator's has reached its end
*
* @var boolean
*/
protected $_finished = false;

/**
* Maintains an in-memory cache of the results yielded by the internal
* iterator.
Expand Down Expand Up @@ -127,6 +134,7 @@ public function valid() {
]);
}

$this->_finished = !$valid;
return $valid;
}

Expand All @@ -137,7 +145,10 @@ public function valid() {
*/
public function next() {
$this->_index++;
parent::next();

if (!$this->_finished) {
parent::next();
}
}

}

0 comments on commit e7f2d27

Please sign in to comment.