Completed
Push — develop ( 7938f1...079ed4 )
by Jaap
04:59
created

File::getInterfaces()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
c 1
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2015 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Reflection\Php;
14
15
use phpDocumentor\Reflection\DocBlock;
16
use phpDocumentor\Reflection\Fqsen;
17
18
/**
19
 * Represents a file in the project.
20
 */
21
final class File
0 ignored issues
show
Complexity introduced by
The class File has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
Loading history...
22
{
23
    /**
24
     * @var DocBlock|null
25
     */
26
    private $docBlock = null;
27
28
    /** @var string $hash */
29
    private $hash;
30
31
    /** @var string $name */
32
    private $name = null;
33
34
    /** @var string $path */
35
    private $path = null;
36
37
    /** @var string|null $source */
38
    private $source = null;
39
40
    /** @var Fqsen[] $namespaces */
41
    private $namespaces = array();
42
43
    /** @var string[] $includes */
44
    private $includes = array();
45
46
    /** @var Function_[] $functions */
47
    private $functions = array();
48
49
    /** @var Constant[] $constants */
50
    private $constants = array();
51
52
    /** @var Class_[] $classes */
53
    private $classes = array();
54
55
    /** @var Interface_[] $interfaces */
56
    private $interfaces = array();
57
58
    /** @var Trait_[] $traits */
59
    private $traits = array();
60
61
    /**
62
     * Initializes a new file descriptor with the given hash of its contents.
63
     *
64
     * @param string $hash An MD5 hash of the contents if this file.
65
     * @param string $path
66
     * @param string|null $source
67
     * @param DocBlock $docBlock
68
     */
69 7
    public function __construct($hash, $path, $source = null, DocBlock $docBlock = null)
70
    {
71 7
        $this->hash = $hash;
72 7
        $this->path = $path;
73 7
        $this->name = basename($path);
74 7
        $this->source = $source;
75 7
        $this->docBlock = $docBlock;
76 7
    }
77
78
    /**
79
     * Returns the hash of the contents for this file.
80
     *
81
     * @return string
82
     */
83 1
    public function getHash()
84
    {
85 1
        return $this->hash;
86
    }
87
88
    /**
89
     * Retrieves the contents of this file.
90
     *
91
     * @return string|null
92
     */
93 1
    public function getSource()
94
    {
95 1
        return $this->source;
96
    }
97
98
    /**
99
     * Returns the namespace fqsens that have been defined in this file.
100
     *
101
     * @return Fqsen[]
102
     */
103 1
    public function getNamespaces()
104
    {
105 1
        return $this->namespaces;
106
    }
107
108
    /**
109
     * Add namespace to file
110
     *
111
     * @param Fqsen $fqsen
112
     */
113 1
    public function addNamespace(Fqsen $fqsen)
114
    {
115 1
        $this->namespaces[(string)$fqsen] = $fqsen;
116 1
    }
117
118
    /**
119
     * Returns a list of all includes that have been declared in this file.
120
     *
121
     * @return string[]
122
     */
123 1
    public function getIncludes()
124
    {
125 1
        return $this->includes;
126
    }
127
128
    /**
129
     * @param string $include
130
     * @return void
131
     */
132 1
    public function addInclude($include)
133
    {
134 1
        $this->includes[$include] = $include;
135 1
    }
136
137
    /**
138
     * Returns a list of constant descriptors contained in this file.
139
     *
140
     * @return Constant[]
141
     */
142 1
    public function getConstants()
143
    {
144 1
        return $this->constants;
145
    }
146
147
    /**
148
     * Add constant to this file.
149
     *
150
     * @param Constant $constant
151
     * @return void
152
     */
153 1
    public function addConstant(Constant $constant)
154
    {
155 1
        $this->constants[(string)$constant->getFqsen()] = $constant;
156 1
    }
157
158
    /**
159
     * Returns a list of function descriptors contained in this file.
160
     *
161
     * @return Function_[]
162
     */
163 1
    public function getFunctions()
164
    {
165 1
        return $this->functions;
166
    }
167
168
    /**
169
     * Add function to this file.
170
     *
171
     * @param Function_ $function
172
     * @return void
173
     */
174 1
    public function addFunction(Function_ $function)
175
    {
176 1
        $this->functions[(string)$function->getFqsen()] = $function;
177 1
    }
178
179
    /**
180
     * Returns a list of class descriptors contained in this file.
181
     *
182
     * @return Class_[]
183
     */
184 1
    public function getClasses()
185
    {
186 1
        return $this->classes;
187
    }
188
189
    /**
190
     * Add Class to this file.
191
     *
192
     * @param Class_ $class
193
     * @return void
194
     */
195 1
    public function addClass(Class_ $class)
196
    {
197 1
        $this->classes[(string)$class->getFqsen()] = $class;
198 1
    }
199
200
    /**
201
     * Returns a list of interface descriptors contained in this file.
202
     *
203
     * @return Interface_[]
204
     */
205 1
    public function getInterfaces()
206
    {
207 1
        return $this->interfaces;
208
    }
209
210
    /**
211
     * Add interface to this file.
212
     *
213
     * @param Interface_ $interface
214
     * @return void
215
     */
216 1
    public function addInterface(Interface_ $interface)
217
    {
218 1
        $this->interfaces[(string)$interface->getFqsen()] = $interface;
219 1
    }
220
221
    /**
222
     * Returns a list of trait descriptors contained in this file.
223
     *
224
     * @return Trait_[]
225
     */
226 1
    public function getTraits()
227
    {
228 1
        return $this->traits;
229
    }
230
231
    /**
232
     * Add trait to this file.
233
     *
234
     * @param Trait_ $trait
235
     * @return void
236
     */
237 1
    public function addTrait(Trait_ $trait)
238
    {
239 1
        $this->traits[(string)$trait->getFqsen()] = $trait;
240 1
    }
241
242
    /**
243
     * Returns the file path relative to the project's root.
244
     *
245
     * @return string
246
     */
247 1
    public function getPath()
248
    {
249 1
        return $this->path;
250
    }
251
    /**
252
     * Returns the DocBlock of the element if available
253
     *
254
     * @return null|DocBlock
255
     */
256 1
    public function getDocBlock()
257
    {
258 1
        return $this->docBlock;
259
    }
260
261
    /**
262
     * Returns the full name of this file
263
     *
264
     * @return string
265
     */
266
    public function getName()
267
    {
268
        return $this->name;
269
    }
270
}
271