Node   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A dotTemplate() 0 3 1
A definition() 0 3 1
A __construct() 0 2 1
A labelTemplate() 0 7 1
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
use PhUml\Code\ClassDefinition;
9
use PhUml\Code\Definition;
10
use PhUml\Code\InterfaceDefinition;
11
use PhUml\Code\TraitDefinition;
12
13
/**
14
 * `ClassDefinition`, `InterfaceDefinition` and `TraitDefinition` objects can be nodes
15
 *
16
 * All nodes labels are HTML tables
17
 */
18
final class Node implements HasDotRepresentation
19
{
20 42
    public function __construct(private readonly Definition $definition)
21
    {
22
    }
23
24 24
    public function definition(): Definition
25
    {
26 24
        return $this->definition;
27
    }
28
29 24
    public function dotTemplate(): string
30
    {
31 24
        return 'node';
32
    }
33
34 23
    public function labelTemplate(): string
35
    {
36 23
        return match ($this->definition::class) {
37 20
            ClassDefinition::class => 'class',
38 14
            InterfaceDefinition::class => 'interface',
39 13
            TraitDefinition::class => 'trait',
40 23
            default => 'enum',
41
        };
42
    }
43
}
44