TraitGraphBuilder::extractFrom()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
c 1
b 0
f 0
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\TraitDefinition;
10
use PhUml\Graphviz\Edge;
11
use PhUml\Graphviz\HasDotRepresentation;
12
use PhUml\Graphviz\Node;
13
14
final class TraitGraphBuilder
15
{
16
    /**
17
     * It creates a node for a Trait
18
     *
19
     * @return HasDotRepresentation[]
20
     */
21 13
    public function extractFrom(TraitDefinition $trait, Codebase $codebase): array
22
    {
23 13
        $dotElements = [new Node($trait)];
24
25 13
        foreach ($trait->traits() as $usedTrait) {
26 8
            $dotElements[] = Edge::use($codebase->get($usedTrait), $trait);
27
        }
28
29 13
        return $dotElements;
30
    }
31
}
32