1 | <?php |
||
49 | class DOMIterator extends \ArrayIterator implements \RecursiveIterator |
||
50 | { |
||
51 | /** |
||
52 | * Registered contexts |
||
53 | * |
||
54 | * @var ContextInterface[] |
||
55 | */ |
||
56 | public $contexts = []; |
||
57 | /** |
||
58 | * Element processor |
||
59 | * |
||
60 | * @var ElementProcessorInterface |
||
61 | */ |
||
62 | protected $elementProcessor; |
||
63 | /** |
||
64 | * Initial parser context |
||
65 | * |
||
66 | * @var ContextInterface |
||
67 | */ |
||
68 | protected $initialContext; |
||
69 | /** |
||
70 | * Element context map |
||
71 | * |
||
72 | * @var array |
||
73 | */ |
||
74 | protected $contextMap = []; |
||
75 | |||
76 | /** |
||
77 | * Recursive DOM node iterator constructor |
||
78 | * |
||
79 | * @param \DOMNodeList|array $nodeList Node list |
||
80 | * @param ContextInterface $initialContext Initial parser context |
||
81 | * @param ElementProcessorInterface $elementProcessor Element processor |
||
82 | * @throws RuntimeException If the node list is invalid |
||
83 | */ |
||
84 | 16 | public function __construct( |
|
107 | |||
108 | /** |
||
109 | * Register an element node |
||
110 | * |
||
111 | * @param \DOMNode $node Node |
||
112 | * @return \DOMNode Node |
||
113 | */ |
||
114 | 15 | protected function registerNode(\DOMNode $node) |
|
131 | |||
132 | /** |
||
133 | * Return the recursive iterator |
||
134 | * |
||
135 | * @return \RecursiveIteratorIterator Recursive iterator |
||
136 | */ |
||
137 | 15 | public function getRecursiveIterator() |
|
141 | |||
142 | /** |
||
143 | * Return whether the current node has child nodes |
||
144 | * |
||
145 | * This method gets called once per element and prior to the call to current(), |
||
146 | * so this seems like the perfect place for the first processing steps (even |
||
147 | * for elements without children). |
||
148 | * |
||
149 | * @return boolean Current node has child nodes |
||
150 | */ |
||
151 | 15 | public function hasChildren() |
|
155 | |||
156 | /** |
||
157 | * Return a child node iterator |
||
158 | * |
||
159 | * @return DOMIterator Child node iterator |
||
160 | */ |
||
161 | 15 | public function getChildren() |
|
170 | |||
171 | /** |
||
172 | * Rewind array back to the start |
||
173 | * |
||
174 | * @return void |
||
175 | */ |
||
176 | 15 | public function rewind() |
|
180 | } |
||
181 |