Passed
Push — master ( f81cc4...5281ab )
by stéphane
04:50
created

Partial::specialProcess()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 13
nc 4
nop 2
dl 0
loc 17
ccs 14
cts 14
cp 1
crap 4
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace Dallgoot\Yaml\Nodes;
4
5
use Dallgoot\Yaml\NodeFactory;
6
7
/**
8
 *
9
 * @author  Stéphane Rebai <[email protected]>
10
 * @license Apache 2.0
11
 * @link    https://github.com/dallgoot/yaml
12
 */
13
class Partial extends NodeGeneric
14
{
15
    /**
16
     * What first character to determine if escaped sequence are allowed
17
     *
18
     * @param      NodeGeneric     $current     The current
19
     * @param      array    $emptyLines  The empty lines
20
     *
21
     * @return     boolean  true to skip normal Loader process, false to continue
22
     */
23 3
    public function specialProcess(NodeGeneric &$current, array &$emptyLines):bool
24
    {
25 3
        $parent = $this->getParent();
26 3
        $addValue = ltrim($current->raw);
27 3
        $separator = ' ';
28 3
        if ($this->raw[-1] === ' ' || $this->raw[-1] === "\n") {
29 1
            $separator = '';
30
        }
31 3
        if ($current instanceof Blank) {
32 1
            $addValue = "\n";
33 1
            $separator = '';
34
        }
35 3
        $node = NodeFactory::get($this->raw.$separator.$addValue, $this->line);
36 3
        $node->indent = null;
37 3
        $parent->value = null;
38 3
        $parent->add($node);
39 3
        return true;
40
    }
41
42 1
    public function build(&$parent = null)
43
    {
44 1
        throw new \ParseError("Partial value found at line $this->line", 1);
45
    }
46
}