Completed
Push — master ( 389baa...c7c5a4 )
by Luis
14:17 queued 08:06
created

Digraph   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A __construct() 0 3 1
A id() 0 3 1
A elements() 0 3 1
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Graphviz;
9
10
/**
11
 * It is a collection of nodes and edges that can be represented using DOT language
12
 *
13
 * @link https://en.wikipedia.org/wiki/DOT_(graph_description_language) See for more details about DOT language
14
 */
15
class Digraph
16
{
17
    /** @var HasDotRepresentation[] */
18
    private $elements;
19
20 93
    public function __construct()
21
    {
22 93
        $this->elements = [];
23 93
    }
24
25
    /** @param HasDotRepresentation[] */
26 84
    public function add(array $definitions): void
27
    {
28 84
        $this->elements = array_merge($this->elements, $definitions);
29 84
    }
30
31
    /** @return HasDotRepresentation[] */
32 90
    public function elements(): array
33
    {
34 90
        return $this->elements;
35
    }
36
37 90
    public function id(): string
38
    {
39 90
        return sha1(mt_rand());
40
    }
41
}
42