Passed
Push — master ( 42571c...f8295f )
by stéphane
09:20
created

Anchor::isAwaitingChild()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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
            try {
19 1
                return $yamlObject->getReference($name);
20
            } catch (\Throwable $e) {
21
                throw new \ParseError("Unknown anchor : '$name' this:".$this->anchor,1,$e);
22
            }
23
        } else {
24 1
            $built = is_null($this->value) ? null : $this->value->build($parent);
25 1
            return $yamlObject->addReference($name, $built);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $yamlObject->addReference($name, $built) targeting Dallgoot\Yaml\YamlObject::addReference() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
26
        }
27
    }
28
29 1
    public function isAwaitingChild(NodeGeneric $node):bool
30
    {
31 1
        return is_null($this->value);
32
    }
33
}