Passed
Pull Request — master (#22)
by Luis
24:40 queued 21:48
created

Node   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 6
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.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
use PhUml\Code\ClassDefinition;
11
use PhUml\Code\Definition;
12
use PhUml\Code\InterfaceDefinition;
13
14
/**
15
 * `ClassDefinition`, `InterfaceDefinition` and `TraitDefinition` objects can be nodes
16
 *
17
 * All nodes labels are HTML tables
18
 */
19
final class Node implements HasDotRepresentation
20
{
21 40
    public function __construct(private readonly Definition $definition)
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 21 at column 49
Loading history...
22
    {
23
    }
24
25 24
    public function definition(): Definition
26
    {
27 24
        return $this->definition;
28
    }
29
30 24
    public function dotTemplate(): string
31
    {
32 24
        return 'node';
33
    }
34
35 23
    public function labelTemplate(): string
36
    {
37 23
        if ($this->definition instanceof ClassDefinition) {
38 20
            return 'class';
39
        }
40 13
        if ($this->definition instanceof InterfaceDefinition) {
41 11
            return 'interface';
42
        }
43 10
        return 'trait';
44
    }
45
}
46