Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
87.50% covered (success)
87.50%
7 / 8
CRAP
91.67% covered (success)
91.67%
11 / 12
DomIterator
0.00% covered (danger)
0.00%
0 / 1
87.50% covered (success)
87.50%
7 / 8
8.04
91.67% covered (success)
91.67%
11 / 12
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 current
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getChildren
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 hasChildren
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 key
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 next
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 rewind
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 valid
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
/**
 * Pop PHP Framework (http://www.popphp.org/)
 *
 * @link       https://github.com/popphp/popphp-framework
 * @author     Nick Sagona, III <dev@nolainteractive.com>
 * @copyright  Copyright (c) 2009-2018 NOLA Interactive, LLC. (http://www.nolainteractive.com)
 * @license    http://www.popphp.org/license     New BSD License
 */
/**
 * @namespace
 */
namespace Pop\Dom;
/**
 * Dom iterator class
 *
 * @category   Pop
 * @package    Pop\Dom
 * @author     Nick Sagona, III <dev@nolainteractive.com>
 * @copyright  Copyright (c) 2009-2018 NOLA Interactive, LLC. (http://www.nolainteractive.com)
 * @license    http://www.popphp.org/license     New BSD License
 * @version    3.2.4
 */
class DomIterator implements \RecursiveIterator
{
    /**
     * Current position
     * @var int
     */
    protected $position;
    /**
     * Node List
     * @var \DOMNodeList
     */
    protected $nodeList;
    /**
     * Constructor
     *
     * Instantiate the DOM iterator object
     *
     * @param \DOMNode $domNode
     */
    public function __construct(\DOMNode $domNode)
    {
        $this->position = 0;
        $this->nodeList = $domNode->childNodes;
    }
    /**
     * Get current method
     * @return \DOMElement
     */
    public function current()
    {
        return $this->nodeList->item($this->position);
    }
    /**
     * Get children method
     * @return DomIterator
     */
    public function getChildren()
    {
        return new self($this->current());
    }
    /**
     * Has children method
     * @return bool
     */
    public function hasChildren()
    {
        return $this->current()->hasChildNodes();
    }
    /**
     * Key method
     * @return int
     */
    public function key()
    {
        return $this->position;
    }
    /**
     * Next method
     */
    public function next()
    {
        $this->position++;
    }
    /**
     * Rewind method
     */
    public function rewind()
    {
        $this->position = 0;
    }
    /**
     * Is valid method
     * @return bool
     */
    public function valid()
    {
        return $this->position < $this->nodeList->length;
    }
}