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 |
||
9 | class Jetpack_Site extends Abstract_Jetpack_Site { |
||
10 | |||
11 | protected function get_mock_option( $name ) { |
||
14 | |||
15 | protected function get_constant( $name ) { |
||
21 | |||
22 | protected function main_network_site() { |
||
25 | |||
26 | protected function wp_version() { |
||
30 | |||
31 | protected function max_upload_size() { |
||
34 | |||
35 | protected function wp_memory_limit() { |
||
38 | |||
39 | protected function wp_max_memory_limit() { |
||
42 | |||
43 | protected function is_main_network() { |
||
46 | |||
47 | public function is_multisite() { |
||
50 | |||
51 | public function is_single_user_site() { |
||
54 | |||
55 | protected function is_version_controlled() { |
||
58 | |||
59 | protected function file_system_write_access() { |
||
62 | |||
63 | protected function current_theme_supports( $feature_name ) { |
||
66 | |||
67 | protected function get_theme_support( $feature_name ) { |
||
70 | |||
71 | public function get_updates() { |
||
74 | |||
75 | function get_id() { |
||
78 | |||
79 | function has_videopress() { |
||
88 | |||
89 | function upgraded_filetypes_enabled() { |
||
92 | |||
93 | function is_mapped_domain() { |
||
96 | |||
97 | function is_redirect() { |
||
100 | |||
101 | function is_following() { |
||
104 | |||
105 | function has_wordads() { |
||
108 | |||
109 | function get_frame_nonce() { |
||
112 | |||
113 | function get_jetpack_frame_nonce() { |
||
116 | |||
117 | function is_headstart_fresh() { |
||
120 | |||
121 | function allowed_file_types() { |
||
135 | |||
136 | function is_private() { |
||
139 | |||
140 | function get_plan() { |
||
143 | |||
144 | function get_subscribers_count() { |
||
147 | |||
148 | function get_capabilities() { |
||
151 | |||
152 | function get_locale() { |
||
155 | |||
156 | function is_jetpack() { |
||
159 | |||
160 | public function get_jetpack_version() { |
||
163 | |||
164 | function get_ak_vp_bundle_enabled() {} |
||
165 | |||
166 | function get_jetpack_seo_front_page_description() { |
||
169 | |||
170 | function get_jetpack_seo_title_formats() { |
||
173 | |||
174 | function get_verification_services_codes() { |
||
177 | |||
178 | function get_podcasting_archive() { |
||
181 | |||
182 | function is_connected_site() { |
||
185 | |||
186 | function current_user_can( $role ) { |
||
189 | |||
190 | function is_fse_active() { |
||
200 | |||
201 | /** |
||
202 | * Post functions |
||
203 | */ |
||
204 | |||
205 | function wrap_post( $post, $context ) { |
||
208 | |||
209 | } |
||
210 |