Literal   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 24
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFinalString() 0 22 6
1
<?php
2
3
namespace Dallgoot\Yaml\Nodes;
4
5
use Dallgoot\Yaml\NodeList;
6
use Dallgoot\Yaml\Nodes\Generic\Literals;
7
8
/**
9
 *
10
 * @author  Stéphane Rebai <[email protected]>
11
 * @license Apache 2.0
12
 * @link    https://github.com/dallgoot/yaml
13
 */
14
class Literal extends Literals
15
{
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
    }
39
}
40