Complex classes like Jetpack_Site often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Jetpack_Site, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 7 | class Jetpack_Site extends Abstract_Jetpack_Site { |
||
| 8 | |||
| 9 | protected function get_mock_option( $name ) { |
||
| 12 | |||
| 13 | protected function get_constant( $name ) { |
||
| 19 | |||
| 20 | protected function main_network_site() { |
||
| 23 | |||
| 24 | protected function wp_version() { |
||
| 28 | |||
| 29 | protected function max_upload_size() { |
||
| 32 | |||
| 33 | protected function is_main_network() { |
||
| 36 | |||
| 37 | public function is_multisite() { |
||
| 40 | |||
| 41 | public function is_single_user_site() { |
||
| 44 | |||
| 45 | protected function is_version_controlled() { |
||
| 48 | |||
| 49 | protected function file_system_write_access() { |
||
| 52 | |||
| 53 | protected function current_theme_supports( $feature_name ) { |
||
| 56 | |||
| 57 | protected function get_theme_support( $feature_name ) { |
||
| 60 | |||
| 61 | public function get_updates() { |
||
| 64 | |||
| 65 | function get_id() { |
||
| 68 | |||
| 69 | function has_videopress() { |
||
| 78 | |||
| 79 | function upgraded_filetypes_enabled() { |
||
| 82 | |||
| 83 | function is_mapped_domain() { |
||
| 86 | |||
| 87 | function is_redirect() { |
||
| 90 | |||
| 91 | function is_following() { |
||
| 94 | |||
| 95 | function has_wordads() { |
||
| 99 | |||
| 100 | function get_frame_nonce() { |
||
| 103 | |||
| 104 | function is_headstart_fresh() { |
||
| 107 | |||
| 108 | function allowed_file_types() { |
||
| 122 | |||
| 123 | function is_private() { |
||
| 126 | |||
| 127 | function get_plan() { |
||
| 130 | |||
| 131 | function get_subscribers_count() { |
||
| 134 | |||
| 135 | function get_capabilities() { |
||
| 138 | |||
| 139 | function get_locale() { |
||
| 142 | |||
| 143 | function is_jetpack() { |
||
| 146 | |||
| 147 | public function get_jetpack_version() { |
||
| 150 | |||
| 151 | function get_ak_vp_bundle_enabled() {} |
||
| 152 | |||
| 153 | function get_jetpack_seo_front_page_description() { |
||
| 156 | |||
| 157 | function get_jetpack_seo_title_formats() { |
||
| 160 | |||
| 161 | function get_verification_services_codes() { |
||
| 164 | |||
| 165 | function get_podcasting_archive() { |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Post functions |
||
| 171 | */ |
||
| 172 | |||
| 173 | function wrap_post( $post, $context ) { |
||
| 176 | |||
| 177 | } |
||
| 178 |