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 |
||
| 13 | class Jetpack_XMLRPC_Methods { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Initialize the main hooks. |
||
| 17 | */ |
||
| 18 | public static function init() { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Adds Jetpack specific methods to the methods added by the Connection package. |
||
| 25 | * |
||
| 26 | * @param array $methods Methods added by the Connection package. |
||
| 27 | */ |
||
| 28 | public function xmlrpc_methods( $methods ) { |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Returns what features are available. Uses the slug of the module files. |
||
| 38 | * |
||
| 39 | * @return array |
||
| 40 | */ |
||
| 41 | View Code Duplication | public static function features_available() { |
|
| 50 | |||
| 51 | /** |
||
| 52 | * Returns what features are enabled. Uses the slug of the modules files. |
||
| 53 | * |
||
| 54 | * @return array |
||
| 55 | */ |
||
| 56 | View Code Duplication | public static function features_enabled() { |
|
| 65 | |||
| 66 | /** |
||
| 67 | * Filters the result of test_connection XMLRPC method |
||
| 68 | * |
||
| 69 | * @return string The current Jetpack version number |
||
| 70 | */ |
||
| 71 | public function test_connection() { |
||
| 74 | } |
||
| 75 |