Passed
Push — master ( d09870...716959 )
by Luis
02:38
created

RawInterfaceBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 6 2
A __construct() 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\Parser\Raw\Builders;
9
10
use PhpParser\Node\Stmt\Interface_;
11
use PhUml\Parser\Raw\RawDefinition;
12
13
/**
14
 * It builds an associative array with meta-information of an interface
15
 *
16
 * The array has the following structure
17
 *
18
 * - `interface` The interface name
19
 * - `methods` The meta-information of the methods of the interface
20
 * - `extends` The name of the interface it extends, if any
21
 *
22
 * @see MethodsBuilder for more details about the methods information
23
 */
24
class RawInterfaceBuilder
25
{
26
    /** @var MethodsBuilder */
27
    private $methodsBuilder;
28
29 72
    public function __construct(MethodsBuilder $methodsBuilder = null)
30
    {
31 72
        $this->methodsBuilder = $methodsBuilder ?? new MethodsBuilder();
32 72
    }
33
34 12
    public function build(Interface_ $interface): RawDefinition
35
    {
36
        return RawDefinition::interface([
37 12
            'interface' => $interface->name,
38 12
            'methods' => $this->methodsBuilder->build($interface),
39 12
            'extends' => !empty($interface->extends) ? end($interface->extends)->getLast() : null,
40
        ]);
41
    }
42
}
43