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

Anchor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

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