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

Anchor::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 10
ccs 8
cts 8
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dallgoot\Yaml\Nodes;
4
5
/**
6
 *
7
 * @author  Stéphane Rebai <[email protected]>
8
 * @license Apache 2.0
9
 * @link    https://github.com/dallgoot/yaml
10
 */
11
class Anchor extends Actions
12
{
13 1
    public function build(&$parent = null)
14
    {
15 1
        $name = substr($this->anchor, 1);
16 1
        $yamlObject = $this->getRoot()->getYamlObject();
17 1
        if ($this->anchor[0] === "*") {
18 1
            return $yamlObject->getReference($name);
19
        } else {
20 1
            $built = $this->value->build($parent);
0 ignored issues
show
Bug introduced by
The method build() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
            /** @scrutinizer ignore-call */ 
21
            $built = $this->value->build($parent);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
21 1
            $yamlObject->addReference($name, $built);
22 1
            return $built;
23
        }
24
    }
25
26 1
    public function isAwaitingChild(NodeGeneric $node):bool
27
    {
28 1
        return is_null($this->value);
29
    }
30
}