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 MockClassMultipleNamespace |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @desc MethodParser to logging |
||
| 15 | * @param string $message |
||
| 16 | */ |
||
| 17 | private function _toLog($message) |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @desc to sum two integers |
||
| 24 | * @param int $a |
||
| 25 | * @param int $b |
||
| 26 | * @return int |
||
| 27 | */ |
||
| 28 | public function sum($a, $b) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param object $object1 @string=name @int=id |
||
| 35 | * @return object $return @string=new_name @int=new_id |
||
| 36 | */ |
||
| 37 | View Code Duplication | public function arrayTest($object1) |
|
| 44 | } |
||
| 45 |