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 ) { |
||
36 | |||
37 | /** |
||
38 | * Returns what features are available. Uses the slug of the module files. |
||
39 | * |
||
40 | * @return array |
||
41 | */ |
||
42 | View Code Duplication | public static function features_available() { |
|
51 | |||
52 | /** |
||
53 | * Returns what features are enabled. Uses the slug of the modules files. |
||
54 | * |
||
55 | * @return array |
||
56 | */ |
||
57 | View Code Duplication | public static function features_enabled() { |
|
66 | |||
67 | /** |
||
68 | * Filters the result of test_connection XMLRPC method |
||
69 | * |
||
70 | * @return string The current Jetpack version number |
||
71 | */ |
||
72 | public function test_connection() { |
||
75 | |||
76 | /** |
||
77 | * Disconnect this blog from the connected wordpress.com account |
||
78 | * |
||
79 | * @return boolean |
||
80 | */ |
||
81 | public function disconnect_blog() { |
||
96 | } |
||
97 |