Digraph::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
4
 */
5
6
namespace PhUml\Graphviz;
7
8
/**
9
 * It is a collection of nodes and edges that can be represented using DOT language
10
 *
11
 * @link https://en.wikipedia.org/wiki/DOT_(graph_description_language) See for more details about DOT language
12
 */
13
final class Digraph
14
{
15
    /** @var HasDotRepresentation[] */
16
    private array $elements;
17
18 27
    public function __construct()
19
    {
20 27
        $this->elements = [];
21
    }
22
23
    /** @param HasDotRepresentation[] $definitions */
24 23
    public function add(array $definitions): void
25
    {
26 23
        $this->elements = array_merge($this->elements, $definitions);
27
    }
28
29
    /** @return HasDotRepresentation[] */
30 26
    public function elements(): array
31
    {
32 26
        return $this->elements;
33
    }
34
35 26
    public function id(): string
36
    {
37 26
        return sha1((string) mt_rand());
38
    }
39
}
40