3 * This file is part of the PHP_CodeCoverage package.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Recursive iterator for PHP_CodeCoverage_Report_Node object graphs.
14 * @since Class available since Release 1.1.0
16 class PHP_CodeCoverage_Report_Node_Iterator implements RecursiveIterator
24 * @var PHP_CodeCoverage_Report_Node[]
31 * @param PHP_CodeCoverage_Report_Node_Directory $node
33 public function __construct(PHP_CodeCoverage_Report_Node_Directory $node)
35 $this->nodes = $node->getChildNodes();
39 * Rewinds the Iterator to the first element.
41 public function rewind()
47 * Checks if there is a current element after calls to rewind() or next().
51 public function valid()
53 return $this->position < count($this->nodes);
57 * Returns the key of the current element.
63 return $this->position;
67 * Returns the current element.
69 * @return PHPUnit_Framework_Test
71 public function current()
73 return $this->valid() ? $this->nodes[$this->position] : null;
77 * Moves forward to next element.
79 public function next()
85 * Returns the sub iterator for the current element.
87 * @return PHP_CodeCoverage_Report_Node_Iterator
89 public function getChildren()
92 $this->nodes[$this->position]
97 * Checks whether the current element has children.
101 public function hasChildren()
103 return $this->nodes[$this->position] instanceof PHP_CodeCoverage_Report_Node_Directory;