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 |
||
| 15 | class Version_Selector { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Checks whether the selected package version should be updated. Composer development |
||
| 19 | * package versions ('9999999-dev' or versions that start with 'dev-') are favored |
||
| 20 | * when the JETPACK_AUTOLOAD_DEV constant is set to true. |
||
| 21 | * |
||
| 22 | * @param String $selected_version The currently selected package version. |
||
| 23 | * @param String $compare_version The package version that is being evaluated to |
||
| 24 | * determine if the version needs to be updated. |
||
| 25 | * |
||
| 26 | * @return Boolean Returns true if the selected package version should be updated, |
||
| 27 | * else false. |
||
| 28 | */ |
||
| 29 | public function is_version_update_required( $selected_version, $compare_version ) { |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Checks whether the given package version is a development version. |
||
| 57 | * |
||
| 58 | * @param String $version The package version. |
||
| 59 | * |
||
| 60 | * @return Boolean True if the version is a dev version, else false. |
||
| 61 | */ |
||
| 62 | View Code Duplication | private function is_package_version_dev( $version ) { |
|
| 69 | } |
||
| 70 |