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 Version_Selector { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Checks whether the selected package version should be updated. Composer development |
||
| 11 | * package versions ('9999999-dev' or versions that start with 'dev-') are favored |
||
| 12 | * when the JETPACK_AUTOLOAD_DEV constant is set to true. |
||
| 13 | * |
||
| 14 | * @param String $selected_version The currently selected package version. |
||
| 15 | * @param String $compare_version The package version that is being evaluated to |
||
| 16 | * determine if the version needs to be updated. |
||
| 17 | * |
||
| 18 | * @return bool Returns true if the selected package version should be updated, |
||
| 19 | * else false. |
||
| 20 | */ |
||
| 21 | public function is_version_update_required( $selected_version, $compare_version ) { |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Checks whether the given package version is a development version. |
||
| 49 | * |
||
| 50 | * @param String $version The package version. |
||
| 51 | * |
||
| 52 | * @return bool True if the version is a dev version, else false. |
||
| 53 | */ |
||
| 54 | View Code Duplication | public function is_dev_version( $version ) { |
|
| 61 | } |
||
| 62 |