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 |
||
| 12 | class PlayerHelper |
||
| 13 | { |
||
| 14 | public static function getSavegameValidation($data) |
||
| 29 | |||
| 30 | View Code Duplication | public function getZipRootPath($zipfilepath) |
|
| 92 | } |
||
| 93 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.