Conditions | 6 |
Paths | 6 |
Total Lines | 26 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | 42 | public function __invoke(DocumentParsedEvent $event): void |
|
22 | { |
||
23 | 42 | $walker = $event->getDocument()->walker(); |
|
24 | 42 | while ($e = $walker->next()) { |
|
25 | // Wait until we're exiting a description list node |
||
26 | 42 | if ($e->isEntering()) { |
|
27 | 42 | continue; |
|
28 | } |
||
29 | |||
30 | 42 | $node = $e->getNode(); |
|
31 | 42 | if (! $node instanceof DescriptionList) { |
|
32 | 42 | continue; |
|
33 | } |
||
34 | |||
35 | 33 | if (! ($next = $node->next()) instanceof DescriptionList) { |
|
36 | 33 | continue; |
|
37 | } |
||
38 | |||
39 | // There's another description list next; merge it into the current one |
||
40 | 33 | foreach ($next->children() as $child) { |
|
41 | 33 | $node->appendChild($child); |
|
42 | } |
||
43 | |||
44 | 33 | $next->detach(); |
|
45 | |||
46 | 33 | $walker->resumeAt($node, false); |
|
47 | } |
||
50 |