Passed
Push — 1.6 ( c2a002 )
by Luis
05:37
created

TraitGraphBuilder::extractFrom()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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