|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of Mandango. |
|
5 * |
|
6 * (c) Pablo Díez <pablodip@gmail.com> |
|
7 * |
|
8 * This source file is subject to the MIT license that is bundled |
|
9 * with this source code in the file LICENSE. |
|
10 */ |
|
11 |
|
12 namespace Mandango\Mondator\Definition; |
|
13 |
|
14 /** |
|
15 * Represents a method of a class. |
|
16 * |
|
17 * @author Pablo Díez <pablodip@gmail.com> |
|
18 * |
|
19 * @api |
|
20 */ |
|
21 class Method |
|
22 { |
|
23 private $visibility; |
|
24 private $name; |
|
25 private $arguments; |
|
26 private $code; |
|
27 private $final; |
|
28 private $static; |
|
29 private $abstract; |
|
30 private $docComment; |
|
31 |
|
32 /** |
|
33 * Constructor. |
|
34 * |
|
35 * @param string $visibility The visibility. |
|
36 * @param string $name The name. |
|
37 * @param string $arguments The arguments (as string). |
|
38 * @param string $code The code. |
|
39 * |
|
40 * @api |
|
41 */ |
|
42 public function __construct($visibility, $name, $arguments, $code) |
|
43 { |
|
44 $this->setVisibility($visibility); |
|
45 $this->setName($name); |
|
46 $this->setArguments($arguments); |
|
47 $this->setCode($code); |
|
48 $this->final = false; |
|
49 $this->static = false; |
|
50 $this->abstract = false; |
|
51 } |
|
52 |
|
53 /** |
|
54 * Set the visibility. |
|
55 * |
|
56 * @param string $visibility The visibility. |
|
57 * |
|
58 * @api |
|
59 */ |
|
60 public function setVisibility($visibility) |
|
61 { |
|
62 $this->visibility = $visibility; |
|
63 } |
|
64 |
|
65 /** |
|
66 * Returns the visibility. |
|
67 * |
|
68 * @return string The visibility. |
|
69 * |
|
70 * @api |
|
71 */ |
|
72 public function getVisibility() |
|
73 { |
|
74 return $this->visibility; |
|
75 } |
|
76 |
|
77 /** |
|
78 * Set the name. |
|
79 * |
|
80 * @param string $name The name. |
|
81 * |
|
82 * @api |
|
83 */ |
|
84 public function setName($name) |
|
85 { |
|
86 $this->name = $name; |
|
87 } |
|
88 |
|
89 /** |
|
90 * Returns the name. |
|
91 * |
|
92 * @return string The name. |
|
93 * |
|
94 * @api |
|
95 */ |
|
96 public function getName() |
|
97 { |
|
98 return $this->name; |
|
99 } |
|
100 |
|
101 /** |
|
102 * Set the arguments. |
|
103 * |
|
104 * Example: "$argument1, &$argument2" |
|
105 * |
|
106 * @param string $arguments The arguments (as string). |
|
107 * |
|
108 * @api |
|
109 */ |
|
110 public function setArguments($arguments) |
|
111 { |
|
112 $this->arguments = $arguments; |
|
113 } |
|
114 |
|
115 /** |
|
116 * Returns the arguments. |
|
117 * |
|
118 * @api |
|
119 */ |
|
120 public function getArguments() |
|
121 { |
|
122 return $this->arguments; |
|
123 } |
|
124 |
|
125 /** |
|
126 * Set the code. |
|
127 * |
|
128 * @param string $code. |
|
129 * |
|
130 * @api |
|
131 */ |
|
132 public function setCode($code) |
|
133 { |
|
134 $this->code = $code; |
|
135 } |
|
136 |
|
137 /** |
|
138 * Returns the code. |
|
139 * |
|
140 * @return string The code. |
|
141 * |
|
142 * @api |
|
143 */ |
|
144 public function getCode() |
|
145 { |
|
146 return $this->code; |
|
147 } |
|
148 |
|
149 /** |
|
150 * Set if the method is final. |
|
151 * |
|
152 * @param bool $final If the method is final. |
|
153 * |
|
154 * @api |
|
155 */ |
|
156 public function setFinal($final) |
|
157 { |
|
158 $this->final = (bool) $final; |
|
159 } |
|
160 |
|
161 /** |
|
162 * Returns if the method is final. |
|
163 * |
|
164 * @return bool If the method is final. |
|
165 * |
|
166 * @api |
|
167 */ |
|
168 public function isFinal() |
|
169 { |
|
170 return $this->final; |
|
171 } |
|
172 |
|
173 /** |
|
174 * Set if the method is static. |
|
175 * |
|
176 * @param bool $static If the method is static. |
|
177 * |
|
178 * @api |
|
179 */ |
|
180 public function setStatic($static) |
|
181 { |
|
182 $this->static = (bool) $static; |
|
183 } |
|
184 |
|
185 /** |
|
186 * Return if the method is static. |
|
187 * |
|
188 * @return bool Returns if the method is static. |
|
189 * |
|
190 * @api |
|
191 */ |
|
192 public function isStatic() |
|
193 { |
|
194 return $this->static; |
|
195 } |
|
196 |
|
197 /** |
|
198 * Set if the method is abstract. |
|
199 * |
|
200 * @param bool $abstract If the method is abstract. |
|
201 * |
|
202 * @api |
|
203 */ |
|
204 public function setAbstract($abstract) |
|
205 { |
|
206 $this->abstract = (bool) $abstract; |
|
207 } |
|
208 |
|
209 /** |
|
210 * Return if the method is abstract. |
|
211 * |
|
212 * @return bool Returns if the method is abstract. |
|
213 * |
|
214 * @api |
|
215 */ |
|
216 public function isAbstract() |
|
217 { |
|
218 return $this->abstract; |
|
219 } |
|
220 |
|
221 /** |
|
222 * Set the doc comment. |
|
223 * |
|
224 * @param string|null $docComment The doc comment. |
|
225 * |
|
226 * @api |
|
227 */ |
|
228 public function setDocComment($docComment) |
|
229 { |
|
230 $this->docComment = $docComment; |
|
231 } |
|
232 |
|
233 /** |
|
234 * Returns the doc comment. |
|
235 * |
|
236 * @return string|null The doc comment. |
|
237 * |
|
238 * @api |
|
239 */ |
|
240 public function getDocComment() |
|
241 { |
|
242 return $this->docComment; |
|
243 } |
|
244 } |