Completed
Push — develop ( 66de6a...7afc9d )
by Jaap
04:46 queued 03:01
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
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
    /**
52
     * Initializes the all properties
53
     *
54
     * @param Fqsen $fqsen
55
     * @param DocBlock|null $docBlock
56
     */
57 2
    public function __construct(Fqsen $fqsen, DocBlock $docBlock = null, Location $location = null)
58
    {
59 2
        if ($location === null) {
60 2
            $location = new Location(-1);
61
        }
62
63 2
        $this->fqsen = $fqsen;
64 2
        $this->docBlock = $docBlock;
65 2
        $this->location = $location;
66 2
    }
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
    }
77
78
    /**
79
     * Add a method to this Trait
80
     *
81
     * @param Method $method
82
     * @return void
83
     */
84 1
    public function addMethod(Method $method)
85
    {
86 1
        $this->methods[(string)$method->getFqsen()] = $method;
87 1
    }
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
    }
98
99
    /**
100
     * Add a property to this Trait.
101
     *
102
     * @param Property $property
103
     * @return void
104
     */
105 1
    public function addProperty(Property $property)
106
    {
107 1
        $this->properties[(string)$property->getFqsen()] = $property;
108 1
    }
109
110
    /**
111
     * Returns the Fqsen of the element.
112
     *
113
     * @return Fqsen
114
     */
115 1
    public function getFqsen()
116
    {
117 1
        return $this->fqsen;
118
    }
119
120
    /**
121
     * Returns the name of the element.
122
     *
123
     * @return string
124
     */
125 1
    public function getName()
126
    {
127 1
        return $this->fqsen->getName();
128
    }
129
130
    /**
131
     * @return null|DocBlock
132
     */
133 1
    public function getDocBlock()
134
    {
135 1
        return $this->docBlock;
136
    }
137
138
    /**
139
     * Returns fqsen of all traits used by this trait.
140
     *
141
     * @return Fqsen[]
142
     */
143 1
    public function getUsedTraits()
144
    {
145 1
        return $this->usedTraits;
146
    }
147
148
    /**
149
     * Add reference to trait used by this trait.
150
     *
151
     * @param Fqsen $fqsen
152
     */
153 1
    public function addUsedTrait(Fqsen $fqsen)
154
    {
155 1
        $this->usedTraits[(string)$fqsen] = $fqsen;
156 1
    }
157
158
    /**
159
     * @return Location
160
     */
161
    public function getLocation()
162
    {
163
        return $this->location;
164
    }
165
}
166