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 |
||
7 | class Sugarcrm |
||
8 | { |
||
9 | /** |
||
10 | * Extracts version number from sugarcrm build files. |
||
11 | * |
||
12 | * @param $path |
||
13 | * |
||
14 | * @return Version |
||
15 | */ |
||
16 | View Code Duplication | public function getBuildVersion($path) |
|
26 | |||
27 | /** |
||
28 | * Extracts flav from sugarcrm build files. |
||
29 | * |
||
30 | * @param $path |
||
31 | * |
||
32 | * @return string |
||
33 | */ |
||
34 | View Code Duplication | public function getBuildFlav($path) |
|
44 | |||
45 | /** |
||
46 | * Verifies if given path represents a valid SugarCRM build. |
||
47 | * |
||
48 | * @param $path |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function isSugarcrmBuild($path) |
||
56 | } |
||
57 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.