| Conditions | 5 |
| Paths | 4 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public static function collapseTextNodes(Node $container) |
||
| 28 | { |
||
| 29 | $walker = $container->walker(); |
||
| 30 | while (($event = $walker->next()) !== null) { |
||
| 31 | if ($event->isEntering()) { |
||
| 32 | $node = $event->getNode(); |
||
| 33 | $next = $node->next(); |
||
| 34 | if ($node instanceof Text && $next instanceof Text) { |
||
| 35 | $node->append($next->getContent()); |
||
| 36 | $next->detach(); |
||
| 37 | // Re-start the next `while` iteration at the same spot as before |
||
| 38 | $walker->resumeAt($node, true); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 | } |
||
| 43 | } |
||
| 44 |