Completed
Push — master ( 9b15b5...fc7d53 )
by Bingo
03:22
created

GraphBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 8
c 1
b 0
f 1
dl 0
loc 41
ccs 0
cts 15
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addVertices() 0 6 2
A addVertex() 0 4 1
1
<?php
2
3
namespace graphp\graph;
4
5
use graphp\edge\EdgeInterface;
6
use graphp\vertex\VertexInterface;
7
8
/**
9
 * Class GraphBuilder
10
 *
11
 * @package graphp\graph
12
 */
13
class GraphBuilder
14
{
15
    /**
16
     * The graph
17
     *
18
     * @var GraphInterface
19
     */
20
    private $graph;
21
    
22
    /**
23
     * Construct the graph
24
     *
25
     * @param GraphInterface $graph - the graph
26
     */
27
    public function __construct(GraphInterface $graph)
28
    {
29
        $this->graph = $graph;
30
    }
31
32
    /**
33
     * Add a vertex to the graph being built
34
     *
35
     * @param VertexInterface $vertex - the vertex
36
     */
37
    public function addVertex(VertexInterface $vertex): self
38
    {
39
        $this->graph->addVertex($vertex);
40
        return $this;
41
    }
42
43
    /**
44
     * Add vertices to the graph being built
45
     *
46
     * @param VertexInterface $vertex - the vertex
47
     */
48
    public function addVertices(array $vertices): self
49
    {
50
        foreach ($vertices as $vertex) {
51
            $this->addVertex($vertex);
52
        }
53
        return $this;
54
    }
55
}
56