_value = $this->_propertyExtractor($valuePath); $this->_key = $this->_propertyExtractor($keyPath); $this->_spacer = $spacer; } /** * Returns the current iteration key * * @return mixed */ public function key() { $extractor = $this->_key; return $extractor($this->_fetchCurrent(), parent::key(), $this); } /** * Returns the current iteration value * * @return string */ public function current() { $extractor = $this->_value; $current = $this->_fetchCurrent(); $spacer = str_repeat($this->_spacer, $this->getDepth()); return $spacer . $extractor($current, parent::key(), $this); } /** * Advances the cursor one position * * @return void */ public function next() { parent::next(); $this->_current = null; } /** * Returns the current iteration element and caches its value * * @return mixed */ protected function _fetchCurrent() { if ($this->_current !== null) { return $this->_current; } return $this->_current = parent::current(); } }