Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
3 | class Ajde_Component_Resource extends Ajde_Component |
||
4 | { |
||
5 | public static function processStatic(Ajde_Template_Parser $parser, $attributes) |
||
11 | |||
12 | public function process() |
||
16 | |||
17 | public function requireResource( |
||
31 | |||
32 | View Code Duplication | public function requirePublicResource( |
|
41 | |||
42 | View Code Duplication | public function requireRemoteResource( |
|
51 | } |
||
52 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: