Passed
Pull Request — master (#30)
by
unknown
46:28 queued 21:27
created

Edge   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 50
ccs 17
cts 17
cp 1
rs 10
c 2
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A toNode() 0 3 1
A __construct() 0 5 1
A inheritance() 0 3 1
A implementation() 0 3 1
A dotTemplate() 0 3 1
A use() 0 3 1
A association() 0 3 1
A options() 0 3 1
A fromNode() 0 3 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
/**
9
 * An edge represents 1 of 3 types of relationships between classes and interfaces
10
 *
11
 * 1. Inheritance
12
 * 2. Interface implementation
13
 * 3. Associations
14
 *      - Via constructor injection
15
 *      - Via class properties
16
 */
17
final class Edge implements HasDotRepresentation
18
{
19 15
    public static function inheritance(HasNodeIdentifier $parent, HasNodeIdentifier $child): Edge
20
    {
21 15
        return new Edge($parent, $child, 'dir=back arrowtail=empty style=solid');
22
    }
23
24 13
    public static function implementation(HasNodeIdentifier $interface, HasNodeIdentifier $class): Edge
25
    {
26 13
        return new Edge($interface, $class, 'dir=back arrowtail=empty style=dashed');
27
    }
28
29 16
    public static function association(HasNodeIdentifier $reference, HasNodeIdentifier $class): Edge
30
    {
31 16
        return new Edge($reference, $class, 'dir=back arrowtail=none style=solid');
32
    }
33
34
    /**
35
     * A trait can be used by another trait or a class
36
     */
37 10
    public static function use(HasNodeIdentifier $trait, HasNodeIdentifier $definition): Edge
38
    {
39 10
        return new Edge($trait, $definition, 'dir=back arrowtail=normal style=solid');
40
    }
41
42 29
    private function __construct(
43
        private readonly HasNodeIdentifier $fromNode,
44
        private readonly HasNodeIdentifier $toNode,
45
        private readonly string $options
46
    ) {
47
    }
48
49 17
    public function fromNode(): HasNodeIdentifier
50
    {
51 17
        return $this->fromNode;
52
    }
53
54 17
    public function toNode(): HasNodeIdentifier
55
    {
56 17
        return $this->toNode;
57
    }
58
59 14
    public function options(): string
60
    {
61 14
        return $this->options;
62
    }
63
64 15
    public function dotTemplate(): string
65
    {
66 15
        return 'edge';
67
    }
68
}
69