Completed
Push — develop ( 66de6a...7afc9d )
by Jaap
04:46 queued 03:01
created

Interface_::addConstant()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
c 1
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
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\Element;
16
use phpDocumentor\Reflection\Fqsen;
17
use phpDocumentor\Reflection\DocBlock;
18
use phpDocumentor\Reflection\Location;
19
20
/**
21
 * Descriptor representing an Interface.
22
 */
23
// @codingStandardsIgnoreStart
24
final class Interface_ implements Element
25
// @codingStandardsIgnoreEnd
26
{
27
    /**
28
     * @var Fqsen Full Qualified Structural Element Name
29
     */
30
    private $fqsen;
31
32
    /**
33
     * @var DocBlock|null
34
     */
35
    private $docBlock;
36
37
    /** @var Constant[] $constants */
38
    protected $constants = array();
39
40
    /** @var Method[] $methods */
41
    protected $methods = array();
42
43
    /** @var Fqsen[] $parents */
44
    protected $parents = array();
45
46
    /**
47
     * @var Location
48
     */
49
    private $location;
50
51
    /**
52
     * Initializes the object.
53
     *
54
     * @param Fqsen $fqsen
55
     * @param Fqsen[] $parents
56
     * @param DocBlock $docBlock
57
     */
58 2
    public function __construct(
59
        Fqsen $fqsen,
60
        array $parents = array(),
61
        DocBlock $docBlock = null,
62
        Location $location = null
63
    ) {
64 2
        if ($location === null) {
65 2
            $location = new Location(-1);
66
        }
67
68 2
        $this->fqsen = $fqsen;
69 2
        $this->docBlock = $docBlock;
70 2
        $this->parents = $parents;
71 2
        $this->location = $location;
72 2
    }
73
74
    /**
75
     * Returns the constants of this interface.
76
     *
77
     * @return Constant[]
78
     */
79 1
    public function getConstants()
80
    {
81 1
        return $this->constants;
82
    }
83
84
    /**
85
     * Add constant to this interface.
86
     *
87
     * @param Constant $constant
88
     * @return void
89
     */
90 1
    public function addConstant(Constant $constant)
91
    {
92 1
        $this->constants[(string)$constant->getFqsen()] = $constant;
93 1
    }
94
95
    /**
96
     * Returns the methods in this interface.
97
     *
98
     * @return Method[]
99
     */
100 1
    public function getMethods()
101
    {
102 1
        return $this->methods;
103
    }
104
105
    /**
106
     * Add method to this interface.
107
     *
108
     * @param Method $method
109
     * @return void
110
     */
111 1
    public function addMethod(Method $method)
112
    {
113 1
        $this->methods[(string)$method->getFqsen()] = $method;
114 1
    }
115
116
    /**
117
     * Returns the Fqsen of the element.
118
     *
119
     * @return Fqsen
120
     */
121 1
    public function getFqsen()
122
    {
123 1
        return $this->fqsen;
124
    }
125
126
    /**
127
     * Returns the name of the element.
128
     *
129
     * @return string
130
     */
131
    public function getName()
132
    {
133
        return $this->fqsen->getName();
134
    }
135
136
    /**
137
     * Returns the DocBlock of this interface if available.
138
     *
139
     * @return null|DocBlock
140
     */
141 1
    public function getDocBlock()
142
    {
143 1
        return $this->docBlock;
144
    }
145
146
    /**
147
     * Returns the Fqsen of the interfaces this interface is extending.
148
     *
149
     * @return Fqsen[]
150
     */
151
    public function getParents()
152
    {
153
        return $this->parents;
154
    }
155
156
    /**
157
     * @return Location
158
     */
159
    public function getLocation()
160
    {
161
        return $this->location;
162
    }
163
}
164