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

NodeActions   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 16
dl 0
loc 26
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 2 1
A __construct() 0 20 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 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
}