Node::definition()   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
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