Completed
Push — 1.8 ( eae5ca )
by Luis
10:56
created

SubGraph::label()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
class SubGraph
11
{
12
    /** @var string */
13
    private $namespace;
14
15
    /** @var Node[] */
16
    private $nodes;
17
18
    public static function for($namespace): SubGraph
19
    {
20
        return new SubGraph($namespace);
21
    }
22
23
    public function add(Node $node): void
24
    {
25
        $this->nodes[] = $node;
26
    }
27
28
    /** @return Node[] */
29
    public function nodes(): array
30
    {
31
        return $this->nodes;
32
    }
33
34
    public function label(): string
35
    {
36
        return strtolower(str_replace('\\', '.', $this->namespace));
37
    }
38
39
    public function clusterId(): string
40
    {
41
        return strtolower('cluster_' . str_replace('\\', '_', $this->namespace));
42
    }
43
44
    private function __construct(string $namespace)
45
    {
46
        $this->namespace = $namespace;
47
        $this->nodes = [];
48
    }
49
}
50