Passed
Push — master ( 844759...f0c5ab )
by stéphane
07:52
created

NodeAnchor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isAwaitingChild() 0 3 1
A build() 0 10 2
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 NodeAnchor extends NodeActions
12
{
13
    public function build(&$parent = null)
14
    {
15
        $name = substr($this->_anchor, 1);
16
        $yamlObject = $this->getRoot()->getYamlObject();
0 ignored issues
show
Bug introduced by
The method getYamlObject() does not exist on Dallgoot\Yaml\NodeAnchor. ( Ignorable by Annotation )

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

16
        $yamlObject = $this->getRoot()->/** @scrutinizer ignore-call */ getYamlObject();

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...
17
        if ($this->_anchor[0] === "*") {
18
            return $yamlObject->getReference($name);
19
        } else {
20
            $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
            $yamlObject->addReference($name, $built);
22
            return $built;
23
        }
24
    }
25
26
    public function isAwaitingChild(Node $node):bool
27
    {
28
        return is_null($this->value);
29
    }
30
}