@@ 247-257 (lines=11) @@ | ||
244 | * |
|
245 | * @return NodeList |
|
246 | */ |
|
247 | public function siblings($selector = null) { |
|
248 | $results = $this->collection()->reduce(function($carry, $node) use ($selector) { |
|
249 | return $carry->merge( |
|
250 | $node->precedingAll($selector)->merge( |
|
251 | $node->followingAll($selector) |
|
252 | ) |
|
253 | ); |
|
254 | }, $this->newNodeList()); |
|
255 | ||
256 | return $results; |
|
257 | } |
|
258 | ||
259 | /** |
|
260 | * NodeList is only array like. Removing items using foreach() has undesired results. |
|
@@ 356-366 (lines=11) @@ | ||
353 | * |
|
354 | * @return NodeList |
|
355 | */ |
|
356 | public function contents() { |
|
357 | $results = $this->collection()->reduce(function($carry, $node) { |
|
358 | if($node->isRemoved()) |
|
359 | return $this->newNodeList(); |
|
360 | return $carry->merge( |
|
361 | $node->newNodeList($node->childNodes) |
|
362 | ); |
|
363 | }, $this->newNodeList()); |
|
364 | ||
365 | return $results; |
|
366 | } |
|
367 | ||
368 | /** |
|
369 | * @param string|NodeList|\DOMNode $input |