ConfigBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 30
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2
ccs 13
cts 13
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addNode() 0 4 1
A withStartNode() 0 4 1
A build() 0 7 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