Conditions | 6 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
16 | 1 | public function getFinalString(NodeList $list, ?int $refIndent = null): string |
|
17 | { |
||
18 | 1 | $result = ''; |
|
19 | 1 | $list = $list->filterComment(); |
|
20 | 1 | if ($this->identifier !== '+') { |
|
21 | 1 | self::litteralStripTrailing($list); |
|
22 | } |
||
23 | 1 | if ($list->count()) { |
|
24 | 1 | $list->setIteratorMode(NodeList::IT_MODE_DELETE); |
|
25 | 1 | $first = $list->shift(); |
|
26 | 1 | $indent = $refIndent ?? $first->indent; |
|
27 | 1 | $result = $this->getChildValue($first, $indent); |
|
28 | 1 | foreach ($list as $child) { |
|
29 | 1 | $value = "\n"; |
|
30 | 1 | if (!($child instanceof Blank)) { |
|
31 | 1 | $newIndent = $indent > 0 ? $child->indent - $indent : 0; |
|
32 | 1 | $value .= str_repeat(' ', $newIndent) . $this->getChildValue($child, $indent); |
|
33 | } |
||
34 | 1 | $result .= $value; |
|
35 | } |
||
36 | } |
||
37 | 1 | return $result; |
|
38 | } |
||
40 |