@@ 167-195 (lines=29) @@ | ||
164 | * |
|
165 | * @return bool |
|
166 | */ |
|
167 | public function hasMethod($name, $traverse = true) |
|
168 | { |
|
169 | foreach ($this->methods as $method) { |
|
170 | ||
171 | if ($name === $method->getName()) { |
|
172 | return true; |
|
173 | } |
|
174 | } |
|
175 | ||
176 | if ($traverse && $this->hasTraits()) { |
|
177 | ||
178 | /** |
|
179 | * @var TraitMetadata $trait |
|
180 | */ |
|
181 | foreach ($this->traits as $trait) { |
|
182 | ||
183 | if ($trait->hasMethod($name, $traverse)) { |
|
184 | return true; |
|
185 | } |
|
186 | } |
|
187 | } |
|
188 | ||
189 | ||
190 | if ($traverse && $this->hasParent()) { |
|
191 | return $this->getParent()->hasMethod($name, $traverse); |
|
192 | } |
|
193 | ||
194 | return false; |
|
195 | } |
|
196 | ||
197 | /** |
|
198 | * Check if class has public method, with optional inheritance tree and trait traverse. |
|
@@ 205-232 (lines=28) @@ | ||
202 | * |
|
203 | * @return bool |
|
204 | */ |
|
205 | public function hasPublicMethod($name, $traverse = true) |
|
206 | { |
|
207 | foreach ($this->methods as $method) { |
|
208 | ||
209 | if ($name === $method->getName()) { |
|
210 | return $method->isPublic(); |
|
211 | } |
|
212 | } |
|
213 | ||
214 | if ($traverse && $this->hasTraits()) { |
|
215 | ||
216 | /** |
|
217 | * @var TraitMetadata $trait |
|
218 | */ |
|
219 | foreach ($this->traits as $trait) { |
|
220 | ||
221 | if ($trait->hasPublicMethod($name, $traverse)) { |
|
222 | return true; |
|
223 | } |
|
224 | } |
|
225 | } |
|
226 | ||
227 | if ($traverse && $this->hasParent()) { |
|
228 | return $this->getParent()->hasPublicMethod($name, $traverse); |
|
229 | } |
|
230 | ||
231 | return false; |
|
232 | } |
|
233 | ||
234 | /** |
|
235 | * Get public method for class, with optional inheritance tree and trait traverse. |