Completed
Push — master ( 3f1b14...d7a449 )
by Luis
14:49 queued 04:53
created

Edge   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 36
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A inheritance() 0 3 1
A implementation() 0 3 1
A toDotLanguage() 0 3 1
A association() 0 3 1
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 Edge implements HasDotRepresentation
11
{
12
    /** @var HasNodeIdentifier */
13
    private $fromNode;
14
15
    /** @var HasNodeIdentifier */
16
    private $toNode;
17
18
    /** @var string */
19
    private $options;
20
21
    public static function inheritance(HasNodeIdentifier $parent, HasNodeIdentifier $child): Edge
22
    {
23
        return new Edge($parent, $child, 'dir=back arrowtail=empty style=solid');
24
    }
25
26
    public static function implementation(HasNodeIdentifier $interface, HasNodeIdentifier $class): Edge
27
    {
28
        return new Edge($interface, $class, 'dir=back arrowtail=normal style=dashed');
29
    }
30
31
    public static function association(HasNodeIdentifier $reference, HasNodeIdentifier $class): Edge
32
    {
33
        return new Edge($reference, $class, 'dir=back arrowtail=none style=dashed');
34
    }
35
36
    public function toDotLanguage(): string
37
    {
38
        return "\"{$this->fromNode->identifier()}\" -> \"{$this->toNode->identifier()}\" [{$this->options}]\n";
39
    }
40
41
    private function __construct(HasNodeIdentifier $nodeA, HasNodeIdentifier $nodeB, string $options)
42
    {
43
        $this->fromNode = $nodeA;
44
        $this->toNode = $nodeB;
45
        $this->options = $options;
46
    }
47
}
48