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 |
||
11 | class UserObserver |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * Listen to the User created event. |
||
16 | * |
||
17 | * @param User $user |
||
18 | * @return void |
||
19 | */ |
||
20 | public function created(User $user) |
||
24 | |||
25 | /** |
||
26 | * Listen to the User deleted event. |
||
27 | */ |
||
28 | View Code Duplication | public function deleted(User $user) |
|
43 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.