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

ConfigBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 30
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
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