ValueNode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 4
dl 0
loc 9
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types=1);
9
10
namespace loophp\phptree\Node;
11
12
use loophp\phptree\Traverser\TraverserInterface;
13
14
/**
15
 * Class ValueNode.
16
 */
17
class ValueNode extends NaryNode implements ValueNodeInterface
18
{
19
    /**
20
     * @var mixed
21
     */
22
    private $value;
23
24
    /**
25
     * ValueNode constructor.
26
     *
27
     * @param mixed|null $value
28
     */
29 37
    public function __construct(
30
        $value,
31
        int $capacity = 0,
32
        ?TraverserInterface $traverser = null,
33
        ?NodeInterface $parent = null
34
    ) {
35 37
        parent::__construct($capacity, $traverser, $parent);
36
37 37
        $this->value = $value;
38 37
    }
39
40 25
    public function getValue()
41
    {
42 25
        return $this->value;
43
    }
44
45 13
    public function label(): string
46
    {
47 13
        return (string) $this->getValue();
48
    }
49
}
50