_iterator = $iterator; return; } /** * Get inner iterator. * * @return \Iterator */ public function getInnerIterator() { return $this->_iterator; } /** * Return the current element. * * @return mixed */ public function current() { return $this->getInnerIterator()->current(); } /** * Return the key of the current element. * * @return mixed */ public function key() { return $this->getInnerIterator()->key(); } /** * Move forward to next element. * * @return void */ public function next() { $this->_previousKey = $this->key(); $this->_previousCurrent = $this->current(); return $this->getInnerIterator()->next(); } /** * Rewind the iterator to the first element. * * @return void */ public function rewind() { $this->_previousKey = -1; $this->_previousCurrent = null; return $this->getInnerIterator()->rewind(); } /** * Check if current position is valid. * * @return bool */ public function valid() { return $this->getInnerIterator()->valid(); } /** * Check whether there is a previous element. * * @return bool */ public function hasPrevious() { return -1 !== $this->_previousKey; } /** * Get previous value. * * @return mixed */ public function getPrevious() { return $this->_previousCurrent; } /** * Get previous key. * * @return mixed */ public function getPreviousKey() { return $this->_previousKey; } }