Completed
Push — master ( 74ffa0...ed410a )
by Mariano
10:21
created

ConfigBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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