Passed
Push — parser-refactoring ( e758c6 )
by Luis
04:05
created

Structure   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 2
A addClass() 0 3 1
A addInterface() 0 3 1
A get() 0 3 1
A __construct() 0 4 1
A definitions() 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
namespace PhUml\Code;
8
9
class Structure
10
{
11
    /** @var ClassDefinition[] */
12
    private $classes;
13
14
    /** @var InterfaceDefinition[] */
15
    private $interfaces;
16
17 75
    public function __construct()
18
    {
19 75
        $this->classes = [];
20 75
        $this->interfaces = [];
21 75
    }
22
23 51
    public function addClass(ClassDefinition $class): void
24
    {
25 51
        $this->classes[$class->name] = $class;
26 51
    }
27
28 30
    public function addInterface(InterfaceDefinition $interface): void
29
    {
30 30
        $this->interfaces[$interface->name] = $interface;
31 30
    }
32
33 45
    public function has(string $name): bool
34
    {
35 45
        return isset($this->interfaces[$name]) || isset($this->classes[$name]);
36
    }
37
38 57
    public function get(string $name): Definition
39
    {
40 57
        return $this->interfaces[$name] ?? $this->classes[$name];
41
    }
42
43
    /** @return Definition[] */
44 12
    public function definitions(): array
45
    {
46 12
        return array_merge($this->classes, $this->interfaces);
47
    }
48
}