Codebase::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
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\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