1 | <?php |
||
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() |
|
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; |
|
157 | |||
158 | /** |
||
159 | * @return Location |
||
160 | */ |
||
161 | public function getLocation() |
||
165 | } |
||
166 |