Passed
Push — cleanup ( 1df3c6...d09870 )
by Luis
12:15
created

RawDefinitions::addExternalClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
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\Parser\Raw;
9
10
/**
11
 * It represents the collection of the classes and interfaces of the codebase being analyzed
12
 *
13
 * This collection of raw definitions is used to build a code `Structure`
14
 *
15
 * @see \PhUml\Parser\StructureBuilder For the details on how a `Structure` is built from a `RawDefinitions` object
16
 */
17
class RawDefinitions
18
{
19
    /** @var RawDefinition[] */
20
    private $definitions;
21
22
    public function __construct()
23
    {
24
        $this->definitions = [];
25
    }
26
27
    public function add(RawDefinition $definition): void
28
    {
29
        $this->definitions[$definition->name()] = $definition;
30
    }
31
32
    public function get(string $name): ?RawDefinition
33
    {
34
        return $this->definitions[$name] ?? null;
35
    }
36
37
    public function addExternalClass(string $name): void
38
    {
39
        $this->definitions[$name] = RawDefinition::externalClass($name);
40
    }
41
42
    public function addExternalInterface(string $name): void
43
    {
44
        $this->definitions[$name] = RawDefinition::externalInterface($name);
45
    }
46
47
    public function has(string $definitionName): bool
48
    {
49
        return isset($this->definitions[$definitionName]);
50
    }
51
52
    /** @return RawDefinition[] */
53
    public function all(): array
54
    {
55
        return $this->definitions;
56
    }
57
}
58