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

GraphBuilder::addVertices()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
cc 2
nc 2
nop 1
crap 6
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