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

NodeActions::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 0
dl 0
loc 2
ccs 1
cts 1
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 NodeActions extends Node
12
{
13 3
    public function __construct(string $nodeString, int $line)
14
    {
15 3
        parent::__construct($nodeString, $line);
16 3
        $trimmed = ltrim($nodeString);
17 3
        $pos = strpos($trimmed, ' ');
18 3
        $name = $trimmed;
19 3
        if (is_int($pos)) {
0 ignored issues
show
introduced by
The condition is_int($pos) is always true.
Loading history...
20 3
            $name = strstr($trimmed, ' ', true);
21 3
            $value = trim(substr($trimmed, $pos + 1));
22 3
            if ($value !== '') {
23 3
                $child = NodeFactory::get($value, $line);
24 3
                $child->indent = null;
25 3
                $this->add($child);
26
            }
27
        }
28 3
        if ($this instanceof NodeTag) {
29 1
            $this->tag = $name;
30 1
            return;
31
        }
32 3
        $this->anchor = $name;
33 3
    }
34
35 1
    public function build(&$parent = null)
36
    {
37
        // Nothing to do here : on purpose
38
    }
39
}