Passed
Push — master ( 3b6a73...d590ba )
by stéphane
02:55
created

NodePartial::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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