ConfigBuilder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Mcustiel\PowerRoute\Utils;
4
5
use Mcustiel\PowerRoute\Common\ConfigOptions;
6
7
class ConfigBuilder
8
{
9
    use StaticCreation;
10
11
    private $start;
12
    private $nodes;
13
14 1
    public function __construct()
15
    {
16 1
        $this->nodes = [];
17 1
    }
18
19 1
    public function addNode($name, NodeBuilder $builder)
20
    {
21 1
        $this->nodes[$name] = $builder->build();
22 1
    }
23
24 1
    public function withStartNode($name)
25
    {
26 1
        $this->start = $name;
27 1
    }
28
29 1
    public function build()
30
    {
31
        return [
32 1
            ConfigOptions::CONFIG_ROOT_NODE => $this->start,
33 1
            ConfigOptions::CONFIG_NODES => $this->nodes,
34 1
        ];
35
    }
36
}
37