Completed
Push — master ( c6ecf3...3eacba )
by stéphane
02:27
created

NodePartial   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 81.25%

Importance

Changes 0
Metric Value
wmc 5
eloc 15
dl 0
loc 32
ccs 13
cts 16
cp 0.8125
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 3 1
A specialProcess() 0 17 4
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 1
    public function specialProcess(Node &$current, array &$emptyLines):bool
22
    {
23 1
        $parent = $this->getParent();
24 1
        $addValue = ltrim($current->raw);
25 1
        $separator = ' ';
26 1
        if ($this->raw[-1] === ' ' || $this->raw[-1] === "\n") {
27
            $separator = '';
28
        }
29 1
        if ($current instanceof NodeBlank) {
30
            $addValue = "\n";
31
            $separator = '';
32
        }
33 1
        $node = NodeFactory::get($this->raw.$separator.$addValue, $this->line);
34 1
        $node->indent = null;
35 1
        $parent->value = null;
36 1
        $parent->add($node);
37 1
        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
}