InterfaceGraphBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractFrom() 0 11 2
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\Builders;
7
8
use PhUml\Code\Codebase;
9
use PhUml\Code\InterfaceDefinition;
10
use PhUml\Graphviz\Edge;
11
use PhUml\Graphviz\HasDotRepresentation;
12
use PhUml\Graphviz\Node;
13
14
/**
15
 * It produces the collection of nodes and edges related to an interface
16
 *
17
 * It creates a node with the interface itself
18
 * It creates one or more edges for every interface it extends, if any
19
 */
20
final class InterfaceGraphBuilder
21
{
22
    /**
23
     * The order in which the nodes and edges are created is as follows
24
     *
25
     * 1. The node representing the interface itself
26
     * 2. The parent interface, if any
27
     *
28
     * @return HasDotRepresentation[]
29
     */
30 13
    public function extractFrom(InterfaceDefinition $interface, Codebase $codebase): array
31
    {
32 13
        $dotElements = [];
33
34 13
        $dotElements[] = new Node($interface);
35
36 13
        foreach ($interface->parents() as $parent) {
37 2
            $dotElements[] = Edge::inheritance($codebase->get($parent), $interface);
38
        }
39
40 13
        return $dotElements;
41
    }
42
}
43