_nestKey = $nestKey; } /** * Returns a traversable containing the children for the current item * * @return \RecursiveIterator */ public function getChildren() { $property = $this->_propertyExtractor($this->_nestKey); return new static($property($this->current()), $this->_nestKey); } /** * Returns true if there is an array or a traversable object stored under the * configured nestKey for the current item * * @return bool */ public function hasChildren() { $property = $this->_propertyExtractor($this->_nestKey); $children = $property($this->current()); if (is_array($children)) { return !empty($children); } return $children instanceof Traversable; } }