Namespace_::addClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @copyright 2010-2018 Mike van Riel<[email protected]>
11
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
12
 * @link      http://phpdoc.org
13
 */
14
15
namespace phpDocumentor\Reflection\Php;
16
17
use phpDocumentor\Reflection\Element;
18
use phpDocumentor\Reflection\Fqsen;
19
20
/**
21
 * Represents a namespace and its children for a project.
22
 */
23
// @codingStandardsIgnoreStart
24
final class Namespace_ implements Element
25
// codingStandardsIgnoreEnd
26
{
27
    /**
28
     * @var Fqsen Full Qualified Structural Element Name
29
     */
30
    private $fqsen;
31
32
    /**
33
     * @var Fqsen[] fqsen of all functions in this namespace
34
     */
35
    private $functions = [];
36
37
    /**
38
     * @var Fqsen[] fqsen of all constants in this namespace
39
     */
40
    private $constants = [];
41
42
    /**
43
     * @var Fqsen[] fqsen of all classes in this namespace
44
     */
45
    private $classes = [];
46
47
    /**
48
     * @var Fqsen[] fqsen of all interfaces in this namespace
49
     */
50
    private $interfaces = [];
51
52
    /**
53
     * @var Fqsen[] fqsen of all traits in this namespace
54
     */
55
    private $traits = [];
56
57
    /**
58
     * Initializes the namespace.
59
     */
60 6
    public function __construct(Fqsen $fqsen)
61
    {
62 6
        $this->fqsen = $fqsen;
63 6
    }
64
65
    /**
66
     * Returns a list of all fqsen of classes in this namespace.
67
     *
68
     * @return Fqsen[]
69
     */
70 1
    public function getClasses(): array
71
    {
72 1
        return $this->classes;
73
    }
74
75
    /**
76
     * Add a class to this namespace.
77
     */
78 1
    public function addClass(Fqsen $class): void
79
    {
80 1
        $this->classes[(string) $class] = $class;
81 1
    }
82
83
    /**
84
     * Returns a list of all constants in this namespace.
85
     *
86
     * @return Fqsen[]
87
     */
88 1
    public function getConstants(): array
89
    {
90 1
        return $this->constants;
91
    }
92
93
    /**
94
     * Add a Constant to this Namespace.
95
     */
96 1
    public function addConstant(Fqsen $contant): void
97
    {
98 1
        $this->constants[(string) $contant] = $contant;
99 1
    }
100
101
    /**
102
     * Returns a list of all functions in this namespace.
103
     *
104
     * @return Fqsen[]
105
     */
106 1
    public function getFunctions(): array
107
    {
108 1
        return $this->functions;
109
    }
110
111
    /**
112
     * Add a function to this namespace.
113
     */
114 1
    public function addFunction(Fqsen $function): void
115
    {
116 1
        $this->functions[(string) $function] = $function;
117 1
    }
118
119
    /**
120
     * Returns a list of all interfaces in this namespace.
121
     *
122
     * @return Fqsen[]
123
     */
124 1
    public function getInterfaces(): array
125
    {
126 1
        return $this->interfaces;
127
    }
128
129
    /**
130
     * Add an interface the this namespace.
131
     */
132 1
    public function addInterface(Fqsen $interface): void
133
    {
134 1
        $this->interfaces[(string) $interface] = $interface;
135 1
    }
136
137
    /**
138
     * Returns a list of all traits in this namespace.
139
     *
140
     * @return Fqsen[]
141
     */
142 1
    public function getTraits(): array
143
    {
144 1
        return $this->traits;
145
    }
146
147
    /**
148
     * Add a trait to this namespace.
149
     */
150 1
    public function addTrait(Fqsen $trait): void
151
    {
152 1
        $this->traits[(string) $trait] = $trait;
153 1
    }
154
155
    /**
156
     * Returns the Fqsen of the element.
157
     */
158 1
    public function getFqsen(): Fqsen
159
    {
160 1
        return $this->fqsen;
161
    }
162
163
    /**
164
     * Returns the name of the element.
165
     */
166 1
    public function getName(): string
167
    {
168 1
        return $this->fqsen->getName();
169
    }
170
}
171