Completed
Push — develop ( 4fc097...cb6ec7 )
by Jaap
01:50
created

Trait_::getLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
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\Element;
17
use phpDocumentor\Reflection\Fqsen;
18
use phpDocumentor\Reflection\Location;
19
20
/**
21
 * Descriptor representing a Trait.
22
 */
23
// @codingStandardsIgnoreStart
24
final class Trait_ 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 Property[] $properties */
38
    private $properties = array();
39
40
    /** @var Method[] $methods */
41
    private $methods = array();
42
43
    /** @var Fqsen[] $usedTraits References to traits consumed by this trait */
44
    private $usedTraits = array();
45
46
    /**
47
     * @var Location
48
     */
49
    private $location;
50
51 2
    /**
52
     * Initializes the all properties
53 2
     *
54 2
     * @param Fqsen $fqsen
55 2
     * @param DocBlock|null $docBlock
56
     */
57
    public function __construct(Fqsen $fqsen, DocBlock $docBlock = null, Location $location = null)
58
    {
59
        if ($location === null) {
60
            $location = new Location(-1);
61
        }
62 1
63
        $this->fqsen = $fqsen;
64 1
        $this->docBlock = $docBlock;
65
        $this->location = $location;
66
    }
67
68
    /**
69
     * Returns the methods of this Trait.
70
     *
71
     * @return Method[]
72
     */
73 1
    public function getMethods()
74
    {
75 1
        return $this->methods;
76 1
    }
77
78
    /**
79
     * Add a method to this Trait
80
     *
81
     * @param Method $method
82
     * @return void
83 1
     */
84
    public function addMethod(Method $method)
85 1
    {
86
        $this->methods[(string)$method->getFqsen()] = $method;
87
    }
88
89
    /**
90
     * Returns the properties of this trait.
91
     *
92
     * @return Property[]
93
     */
94 1
    public function getProperties()
95
    {
96 1
        return $this->properties;
97 1
    }
98
99
    /**
100
     * Add a property to this Trait.
101
     *
102
     * @param Property $property
103
     * @return void
104 1
     */
105
    public function addProperty(Property $property)
106 1
    {
107
        $this->properties[(string)$property->getFqsen()] = $property;
108
    }
109
110
    /**
111
     * Returns the Fqsen of the element.
112
     *
113
     * @return Fqsen
114 1
     */
115
    public function getFqsen()
116 1
    {
117
        return $this->fqsen;
118
    }
119
120
    /**
121
     * Returns the name of the element.
122 1
     *
123
     * @return string
124 1
     */
125
    public function getName()
126
    {
127
        return $this->fqsen->getName();
128
    }
129
130
    /**
131
     * @return null|DocBlock
132 1
     */
133
    public function getDocBlock()
134 1
    {
135
        return $this->docBlock;
136
    }
137
138
    /**
139
     * Returns fqsen of all traits used by this trait.
140
     *
141
     * @return Fqsen[]
142 1
     */
143
    public function getUsedTraits()
144 1
    {
145 1
        return $this->usedTraits;
146
    }
147
148
    /**
149
     * Add reference to trait used by this trait.
150
     *
151
     * @param Fqsen $fqsen
152
     */
153
    public function addUsedTrait(Fqsen $fqsen)
154
    {
155
        $this->usedTraits[(string)$fqsen] = $fqsen;
156
    }
157
158
    /**
159
     * @return Location
160
     */
161
    public function getLocation()
162
    {
163
        return $this->location;
164
    }
165
}
166