1 | <?php |
||
16 | class Node |
||
17 | { |
||
18 | /** |
||
19 | * @var XMLReader |
||
20 | */ |
||
21 | protected $reader; |
||
22 | |||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | private $nodeType; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $name; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $localName; |
||
37 | |||
38 | /** |
||
39 | * @var SimpleXMLElement |
||
40 | */ |
||
41 | private $simpleXML; |
||
42 | |||
43 | /** |
||
44 | * @var AttributeIterator |
||
45 | */ |
||
46 | private $attributes; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | private $string; |
||
52 | |||
53 | 26 | public function __construct(XMLReader $reader) |
|
59 | |||
60 | /** |
||
61 | * @inheritdoc |
||
62 | */ |
||
63 | 1 | public function __toString() |
|
71 | |||
72 | /** |
||
73 | * @return SimpleXMLElement |
||
74 | */ |
||
75 | 1 | public function getSimpleXMLElement() |
|
88 | |||
89 | /** |
||
90 | * @return AttributeIterator|array |
||
91 | */ |
||
92 | 18 | public function getAttributes() |
|
100 | |||
101 | /** |
||
102 | * @param string $name |
||
103 | * @param null $default |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | public function getAttribute(string $name, $default = null) |
||
111 | |||
112 | /** |
||
113 | * @param null $name |
||
114 | * @param bool $descendantAxis |
||
115 | * |
||
116 | * @return ChildElementIterator |
||
117 | */ |
||
118 | 1 | public function getChildElements($name = null, bool $descendantAxis = false) : ChildElementIterator |
|
122 | |||
123 | /** |
||
124 | * @return ChildIterator|Node[] |
||
125 | */ |
||
126 | public function getChildren() : ChildIterator |
||
130 | |||
131 | /** |
||
132 | * @return string name |
||
133 | */ |
||
134 | 5 | public function getName() |
|
138 | |||
139 | /** |
||
140 | * @return string local name |
||
141 | */ |
||
142 | public function getLocalName() |
||
146 | |||
147 | public function getReader() |
||
151 | |||
152 | /** |
||
153 | * @return string |
||
154 | */ |
||
155 | public function readOuterXml() |
||
159 | |||
160 | /** |
||
161 | * XMLReader expand node and import it into a DOMNode with a DOMDocument |
||
162 | * |
||
163 | * This is for example useful for DOMDocument::saveXML() @see readOuterXml |
||
164 | * or getting a SimpleXMLElement out of it @see getSimpleXMLElement |
||
165 | * |
||
166 | * @throws BadMethodCallException |
||
167 | * |
||
168 | * @param DOMNode $baseNode |
||
169 | * |
||
170 | * @return DOMNode |
||
171 | */ |
||
172 | 2 | public function expand(DOMNode $baseNode = null) |
|
194 | |||
195 | /** |
||
196 | * Decorated method |
||
197 | * |
||
198 | * @throws BadMethodCallException |
||
199 | * @return string |
||
200 | */ |
||
201 | 6 | public function readString() |
|
205 | |||
206 | /** |
||
207 | * Return node-type as human readable string (constant name) |
||
208 | * |
||
209 | * @param null $nodeType |
||
210 | * |
||
211 | * @return string |
||
212 | */ |
||
213 | 15 | public function getNodeTypeName($nodeType = null) |
|
242 | |||
243 | /** |
||
244 | * decorate method calls |
||
245 | * |
||
246 | * @param string $name |
||
247 | * @param array $args |
||
248 | * |
||
249 | * @return mixed |
||
250 | */ |
||
251 | public function __call($name, $args) |
||
255 | |||
256 | /** |
||
257 | * decorate property get |
||
258 | * |
||
259 | * @param string $name |
||
260 | * |
||
261 | * @return string |
||
262 | */ |
||
263 | 2 | public function __get($name) |
|
267 | |||
268 | /** |
||
269 | * debug utility method |
||
270 | * |
||
271 | * @param XMLReader $reader |
||
272 | * @param bool $return (optional) prints by default but can return string |
||
273 | * |
||
274 | * @return string|null |
||
275 | */ |
||
276 | 14 | public static function dump(XMLReader $reader, bool $return = false) |
|
324 | } |
||
325 |