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 |
||
| 8 | View Code Duplication | class RunnableUpdate extends Update implements DDLPreparable { |
|
| 9 | use CreateDDLRunnable; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @param MySQL $db |
||
| 13 | * @param array $options |
||
| 14 | */ |
||
| 15 | public function __construct(MySQL $db, array $options = []) { |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param array $params |
||
| 21 | * @return int |
||
| 22 | */ |
||
| 23 | public function run(array $params = array()) { |
||
| 27 | |||
| 28 | /** |
||
| 29 | */ |
||
| 30 | public function prepare() { |
||
| 33 | } |
||
| 34 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.