Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
12 / 12
DomIterator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
8 / 8
8
100.00% covered (success)
100.00%
12 / 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
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 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
1<?php
2/**
3 * Pop PHP Framework (http://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/popphp-framework
6 * @author     Nick Sagona, III <dev@nolainteractive.com>
7 * @copyright  Copyright (c) 2009-2021 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Dom;
15
16/**
17 * Dom iterator class
18 *
19 * @category   Pop
20 * @package    Pop\Dom
21 * @author     Nick Sagona, III <dev@nolainteractive.com>
22 * @copyright  Copyright (c) 2009-2021 NOLA Interactive, LLC. (http://www.nolainteractive.com)
23 * @license    http://www.popphp.org/license     New BSD License
24 * @version    3.3.0
25 */
26class DomIterator implements \RecursiveIterator
27{
28
29    /**
30     * Current position
31     * @var int
32     */
33    protected $position;
34
35    /**
36     * Node List
37     * @var \DOMNodeList
38     */
39    protected $nodeList;
40
41    /**
42     * Constructor
43     *
44     * Instantiate the DOM iterator object
45     *
46     * @param \DOMNode $domNode
47     */
48    public function __construct(\DOMNode $domNode)
49    {
50        $this->position = 0;
51        $this->nodeList = $domNode->childNodes;
52    }
53
54    /**
55     * Get current method
56     * @return \DOMNode
57     */
58    public function current()
59    {
60        return $this->nodeList->item($this->position);
61    }
62
63    /**
64     * Get children method
65     * @return DomIterator
66     */
67    public function getChildren()
68    {
69        return new self($this->current());
70    }
71
72    /**
73     * Has children method
74     * @return bool
75     */
76    public function hasChildren()
77    {
78        return $this->current()->hasChildNodes();
79    }
80
81    /**
82     * Key method
83     * @return int
84     */
85    public function key()
86    {
87        return $this->position;
88    }
89
90    /**
91     * Next method
92     */
93    public function next()
94    {
95        $this->position++;
96    }
97
98    /**
99     * Rewind method
100     */
101    public function rewind()
102    {
103        $this->position = 0;
104    }
105
106    /**
107     * Is valid method
108     * @return bool
109     */
110    public function valid()
111    {
112        return $this->position < $this->nodeList->length;
113    }
114
115}