Codebase   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 29
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A definitions() 0 3 1
A has() 0 3 1
A add() 0 3 1
A __construct() 0 3 1
A get() 0 3 1
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\Code;
7
8
/**
9
 * Collection of all the classes and interfaces definitions found in a given directory
10
 */
11
final class Codebase
12
{
13
    /** @var Definition[] $definitions */
14
    private array $definitions;
15
16 80
    public function __construct()
17
    {
18 80
        $this->definitions = [];
19
    }
20
21 64
    public function add(Definition $definition): void
22
    {
23 64
        $this->definitions[$definition->name()->fullName()] = $definition;
24
    }
25
26 36
    public function has(Name $name): bool
27
    {
28 36
        return isset($this->definitions[$name->fullName()]);
29
    }
30
31 36
    public function get(Name $name): Definition
32
    {
33 36
        return $this->definitions[$name->fullName()];
34
    }
35
36
    /** @return Definition[] */
37 55
    public function definitions(): array
38
    {
39 55
        return $this->definitions;
40
    }
41
}
42