* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class ShutdownPoolIterator extends BaseIterator implements Iterator {
+ /**
+ * Key for the global list index
+ */
+ private $indexKey = 0;
+
/**
* Protected constructor
*
* Getter for current value from group or generic
*
* @return $current Current value in iteration
+ * @throws IndexOutOfBoundsException If $indexKey is out of bounds
*/
public function current () {
// Default is null
$current = null;
- $this->partialStub('Please implement this method.');
+ // Is the entry valid?
+ if (!$this->valid()) {
+ // Throw an exception here
+ throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
+ } // END - if
+
+ // Now get the entry
+ $current = $this->getListInstance()->getEntry($this->key());
// Return it
return $current;
/**
* Getter for key from group or generic
*
- * @return $key Current key in iteration
+ * @return $indexKey Current key in iteration
*/
public function key () {
- // Default is null
- $key = null;
-
- $this->partialStub('Please implement this method.');
-
- // Return it
- return $key;
+ return $this->indexKey;
}
/**
* @return void
*/
public function next () {
- $this->partialStub('Please implement this method.');
+ $this->indexKey++;
}
/**
* @return void
*/
public function rewind () {
- $this->partialStub('Please implement this method.');
+ $this->indexKey = 0;
}
/**
* Checks wether the current entry is valid (not at the end of the list)
*
- * @return void
+ * @return $isValid Wether the current entry is there
*/
public function valid () {
- $this->partialStub('Please implement this method.');
+ // Check for total active clients and if we are not at the end
+ $isValid = ($this->key() < $this->getListInstance()->count());
+
+ // Return result
+ return $isValid;
}
}