Passed
Push — cleanup ( 1df3c6 )
by Luis
14:39
created

InterfaceGraphBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A extractFrom() 0 11 2
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\Builders;
9
10
use PhUml\Code\InterfaceDefinition;
11
use PhUml\Graphviz\Edge;
12
use PhUml\Graphviz\Node;
13
14
class InterfaceGraphBuilder
15
{
16
    /** @var NodeLabelBuilder */
17
    private $labelBuilder;
18
19
    public function __construct(NodeLabelBuilder $labelBuilder)
20
    {
21
        $this->labelBuilder = $labelBuilder;
22
    }
23
24
    /**
25
     * @return \PhUml\Graphviz\HasDotRepresentation[]
26
     */
27
    public function extractFrom(InterfaceDefinition $interface): array
28
    {
29
        $dotElements = [];
30
31
        $dotElements[] = new Node($interface, $this->labelBuilder->forInterface($interface));
32
33
        if ($interface->hasParent()) {
34
            $dotElements[] = Edge::inheritance($interface->extends, $interface);
35
        }
36
37
        return $dotElements;
38
    }
39
}
40