Total Complexity | 42 |
Total Lines | 506 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like WordPoints_Points_Un_Installer 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.
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 WordPoints_Points_Un_Installer, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
19 | class WordPoints_Points_Un_Installer extends WordPoints_Un_Installer_Base { |
||
20 | |||
21 | /** |
||
22 | * Disable the legacy points hooks. |
||
23 | * |
||
24 | * @since 2.1.0 |
||
25 | * @deprecated 2.4.0 |
||
26 | */ |
||
27 | protected function disable_legacy_hooks() { |
||
28 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Update the plugin to 1.2.0. |
||
33 | * |
||
34 | * @since 1.8.0 |
||
35 | * @deprecated 2.4.0 |
||
36 | */ |
||
37 | protected function update_network_to_1_2_0() { |
||
38 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Update the plugin to 1.2.0. |
||
43 | * |
||
44 | * @since 1.8.0 |
||
45 | * @deprecated 2.4.0 |
||
46 | */ |
||
47 | protected function update_single_to_1_2_0() { |
||
48 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Remove the points logs of users who have been deleted. |
||
53 | * |
||
54 | * @since 1.8.0 |
||
55 | * @deprecated 2.4.0 |
||
56 | */ |
||
57 | protected function _1_2_0_remove_points_logs_for_deleted_users() { |
||
58 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Regenerate the points logs for deleted posts. |
||
63 | * |
||
64 | * @since 1.8.0 |
||
65 | * @deprecated 2.4.0 |
||
66 | */ |
||
67 | protected function _1_2_0_regenerate_points_logs_for_deleted_posts() { |
||
68 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Regenerate the points logs for deleted comments. |
||
73 | * |
||
74 | * @since 1.8.0 |
||
75 | * @deprecated 2.4.0 |
||
76 | */ |
||
77 | protected function _1_2_0_regenerate_points_logs_for_deleted_comments() { |
||
78 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Update a network to 1.4.0. |
||
83 | * |
||
84 | * @since 1.8.0 |
||
85 | * @deprecated 2.4.0 |
||
86 | */ |
||
87 | protected function update_network_to_1_4_0() { |
||
88 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Update a site on the network to 1.4.0. |
||
93 | * |
||
94 | * @since 1.8.0 |
||
95 | * @deprecated 2.4.0 |
||
96 | */ |
||
97 | protected function update_site_to_1_4_0() { |
||
98 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Update a single site to 1.4.0. |
||
103 | * |
||
104 | * @since 1.8.0 |
||
105 | * @deprecated 2.4.0 |
||
106 | */ |
||
107 | protected function update_single_to_1_4_0() { |
||
108 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Split the post delete points hooks from the post points hooks. |
||
113 | * |
||
114 | * @since 1.8.0 |
||
115 | * @deprecated 2.4.0 |
||
116 | */ |
||
117 | protected function _1_4_0_split_post_hooks() { |
||
118 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Split the commend removed points hooks from the comment points hooks. |
||
123 | * |
||
124 | * @since 1.8.0 |
||
125 | * @deprecated 2.4.0 |
||
126 | */ |
||
127 | protected function _1_4_0_split_comment_hooks() { |
||
128 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Split a set of points hooks. |
||
133 | * |
||
134 | * @since 1.8.0 |
||
135 | * @deprecated 2.4.0 |
||
136 | * |
||
137 | * @param string $hook The slug of the hook type to split. |
||
138 | * @param string $new_hook The slug of the new hook that this one is being split into. |
||
139 | * @param string $key The settings key for the hook that holds the points. |
||
140 | * @param string $split_key The settings key for points that is being split. |
||
141 | */ |
||
142 | protected function _1_4_0_split_points_hooks( $hook, $new_hook, $key, $split_key ) { |
||
143 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * Clean the settings for the post and comment points hooks. |
||
148 | * |
||
149 | * Removes old and no longer used settings from the comment and post points hooks. |
||
150 | * |
||
151 | * @since 1.8.0 |
||
152 | * @deprecated 2.4.0 |
||
153 | * |
||
154 | * @filter wordpoints_points_hook_update_callback Added during the update to 1.4.0. |
||
155 | * |
||
156 | * @param array $instance The settings for the instance. |
||
157 | * @param array $new_instance The new settings for the instance. |
||
158 | * @param array $old_instance The old settings for the instance. |
||
159 | * @param WordPoints_Points_Hook $hook The hook object. |
||
160 | * |
||
161 | * @return array The filtered instance settings. |
||
162 | */ |
||
163 | public function _1_4_0_clean_hook_settings( $instance, $new_instance, $old_instance, $hook ) { |
||
164 | |||
165 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
166 | |||
167 | return $instance; |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * Clean the comment_approve points logs for posts that have been deleted. |
||
172 | * |
||
173 | * @since 1.8.0 |
||
174 | * @deprecated 2.4.0 |
||
175 | */ |
||
176 | protected function _1_4_0_clean_points_logs() { |
||
177 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
178 | } |
||
179 | |||
180 | /** |
||
181 | * Update a site on the network to 1.5.0. |
||
182 | * |
||
183 | * Prior to 1.5.0, capabilities weren't automatically added to new sites when |
||
184 | * WordPoints was in network mode. |
||
185 | * |
||
186 | * @since 1.8.0 |
||
187 | * @deprecated 2.4.0 |
||
188 | */ |
||
189 | protected function update_site_to_1_5_0() { |
||
190 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
191 | } |
||
192 | |||
193 | /** |
||
194 | * Update the network to 1.5.1. |
||
195 | * |
||
196 | * @since 1.8.0 |
||
197 | * @deprecated 2.4.0 |
||
198 | */ |
||
199 | protected function update_network_to_1_5_1() { |
||
200 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
201 | } |
||
202 | |||
203 | /** |
||
204 | * Update a single site to 1.5.1. |
||
205 | * |
||
206 | * @since 1.8.0 |
||
207 | * @deprecated 2.4.0 |
||
208 | */ |
||
209 | protected function update_single_to_1_5_1() { |
||
210 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * Update a site to 1.8.0. |
||
215 | * |
||
216 | * @since 1.8.0 |
||
217 | * @deprecated 2.4.0 |
||
218 | */ |
||
219 | protected function update_site_to_1_8_0() { |
||
220 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
221 | } |
||
222 | |||
223 | /** |
||
224 | * Update a network to 1.9.0. |
||
225 | * |
||
226 | * @since 1.9.0 |
||
227 | * @deprecated 2.4.0 |
||
228 | */ |
||
229 | protected function update_network_to_1_9_0() { |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * Update a site to 1.9.0. |
||
235 | * |
||
236 | * @since 1.9.0 |
||
237 | * @deprecated 2.4.0 |
||
238 | */ |
||
239 | protected function update_site_to_1_9_0() { |
||
240 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
241 | } |
||
242 | |||
243 | /** |
||
244 | * Update a single site to 1.9.0. |
||
245 | * |
||
246 | * @since 1.9.0 |
||
247 | * @deprecated 2.4.0 |
||
248 | */ |
||
249 | protected function update_single_to_1_9_0() { |
||
250 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * Combine any Comment/Comment Removed or Post/Post Delete hook instance pairs. |
||
255 | * |
||
256 | * @since 1.9.0 |
||
257 | * @deprecated 2.4.0 |
||
258 | * |
||
259 | * @param string $type The primary hook type that awards the points. |
||
260 | * @param string $reverse_type The counterpart hook type that reverses points. |
||
261 | */ |
||
262 | protected function _1_9_0_combine_hooks( $type, $reverse_type ) { |
||
263 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
264 | } |
||
265 | |||
266 | /** |
||
267 | * Update a site to 1.10.0. |
||
268 | * |
||
269 | * @since 1.10.0 |
||
270 | * @deprecated 2.4.0 |
||
271 | */ |
||
272 | protected function update_network_to_1_10_0() { |
||
273 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
274 | } |
||
275 | |||
276 | /** |
||
277 | * Update a single site to 1.10.0. |
||
278 | * |
||
279 | * @since 1.10.0 |
||
280 | * @deprecated 2.4.0 |
||
281 | */ |
||
282 | protected function update_single_to_1_10_0() { |
||
283 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
284 | } |
||
285 | |||
286 | /** |
||
287 | * Delete the no longer used 'post_title' metadata from post delete points logs. |
||
288 | * |
||
289 | * @since 1.10.0 |
||
290 | * @deprecated 2.4.0 |
||
291 | * |
||
292 | * @param bool $network_wide Whether to delete all of the metadata for the whole |
||
293 | * network, or just the current site (default). |
||
294 | */ |
||
295 | protected function _1_10_0_delete_post_title_points_log_meta( $network_wide = false ) { |
||
296 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * Update a site to 2.0.0. |
||
301 | * |
||
302 | * @since 2.0.0 |
||
303 | * @deprecated 2.4.0 |
||
304 | */ |
||
305 | protected function update_network_to_2_0_0() { |
||
306 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
307 | } |
||
308 | |||
309 | /** |
||
310 | * Update a single site to 2.0.0. |
||
311 | * |
||
312 | * @since 2.0.0 |
||
313 | * @deprecated 2.4.0 |
||
314 | */ |
||
315 | protected function update_single_to_2_0_0() { |
||
316 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
317 | } |
||
318 | |||
319 | /** |
||
320 | * Update a multisite network to 2.1.0 |
||
321 | * |
||
322 | * @since 2.1.0 |
||
323 | * @deprecated 2.4.0 |
||
324 | */ |
||
325 | protected function update_network_to_2_1_0() { |
||
326 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
327 | } |
||
328 | |||
329 | /** |
||
330 | * Update a single site to 2.1.0 |
||
331 | * |
||
332 | * @since 2.1.0 |
||
333 | * @deprecated 2.4.0 |
||
334 | */ |
||
335 | protected function update_single_to_2_1_0() { |
||
336 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
337 | } |
||
338 | |||
339 | /** |
||
340 | * Update a site on the network to 2.1.4. |
||
341 | * |
||
342 | * @since 2.1.4 |
||
343 | * @deprecated 2.4.0 |
||
344 | */ |
||
345 | protected function update_site_to_2_1_4() { |
||
346 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
347 | } |
||
348 | |||
349 | /** |
||
350 | * Update a single site to 2.1.4. |
||
351 | * |
||
352 | * @since 2.1.4 |
||
353 | * @deprecated 2.4.0 |
||
354 | */ |
||
355 | protected function update_single_to_2_1_4() { |
||
356 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
357 | } |
||
358 | |||
359 | /** |
||
360 | * Get the post types used by the hooks API. |
||
361 | * |
||
362 | * @since 2.1.4 |
||
363 | * @deprecated 2.4.0 |
||
364 | * |
||
365 | * @return string[] The post types that we award points for. |
||
366 | */ |
||
367 | protected function _2_1_4_get_post_types() { |
||
368 | |||
369 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
370 | |||
371 | return array(); |
||
372 | } |
||
373 | |||
374 | /** |
||
375 | * Get the slugs of the reversal events that we are interested in. |
||
376 | * |
||
377 | * @since 2.1.4 |
||
378 | * @deprecated 2.4.0 |
||
379 | * |
||
380 | * @return array The slugs of the events. |
||
381 | */ |
||
382 | protected function _2_1_4_get_reversal_log_types( $post_types ) { |
||
383 | |||
384 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
385 | |||
386 | return array(); |
||
387 | } |
||
388 | |||
389 | /** |
||
390 | * Get all duplicate logs for a single hit. |
||
391 | * |
||
392 | * Finds all points logs where two logs are for the same hit, and returns the |
||
393 | * IDs of those hits and the IDs of the logs for each. |
||
394 | * |
||
395 | * @since 2.1.4 |
||
396 | * @deprecated 2.4.0 |
||
397 | * |
||
398 | * @return object[] Array of rows, each row consisting of the `hit_id` and |
||
399 | * `log_ids`, the later being the IDs of all of the logs |
||
400 | * concatenated together using commas. |
||
401 | */ |
||
402 | protected function _2_1_4_get_hits_with_multiple_logs() { |
||
407 | } |
||
408 | |||
409 | /** |
||
410 | * Get the IDs of the original logs for a bunch of reversal logs. |
||
411 | * |
||
412 | * @since 2.1.4 |
||
413 | * @deprecated 2.4.0 |
||
414 | * |
||
415 | * @param int[] $log_ids The IDs of the reversal logs. |
||
416 | * |
||
417 | * @return array The IDs of the original logs. |
||
418 | */ |
||
419 | protected function _2_1_4_get_original_log_ids( $log_ids ) { |
||
420 | |||
421 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
422 | |||
423 | return array(); |
||
424 | } |
||
425 | |||
426 | /** |
||
427 | * Delete some points logs. |
||
428 | * |
||
429 | * The hits for the logs will also be deleted. |
||
430 | * |
||
431 | * @since 2.1.4 |
||
432 | * @deprecated 2.4.0 |
||
433 | * |
||
434 | * @param int[] $log_ids The IDs of the logs to delete. |
||
435 | */ |
||
436 | protected function _2_1_4_delete_logs( $log_ids ) { |
||
437 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
438 | } |
||
439 | |||
440 | /** |
||
441 | * Delete some hook hits. |
||
442 | * |
||
443 | * @since 2.1.4 |
||
444 | * @deprecated 2.4.0 |
||
445 | * |
||
446 | * @param int[] $hit_ids The IDs of the hits to delete. |
||
447 | */ |
||
448 | protected function _2_1_4_delete_hits( $hit_ids ) { |
||
449 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
450 | } |
||
451 | |||
452 | /** |
||
453 | * Cleans out any other logs relating to a post. |
||
454 | * |
||
455 | * @since 2.1.4 |
||
456 | * @deprecated 2.4.0 |
||
457 | * |
||
458 | * @param int $post_id The ID of the post to clean logs for. |
||
459 | * @param string $post_type The post type that this post is of. |
||
460 | * @param int[] $logs_to_delete A list of logs that are being deleted. |
||
461 | * |
||
462 | * @return int[] The list of logs to be deleted. |
||
463 | */ |
||
464 | protected function _2_1_4_clean_other_logs( $post_id, $post_type, $logs_to_delete ) { |
||
465 | |||
466 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
467 | |||
468 | return array(); |
||
469 | } |
||
470 | |||
471 | /** |
||
472 | * Give a user back the points that a log removed. |
||
473 | * |
||
474 | * @since 2.1.4 |
||
475 | * @deprecated 2.4.0 |
||
476 | * |
||
477 | * @param object $log The points log object. |
||
478 | */ |
||
479 | protected function _2_1_4_revert_log( $log ) { |
||
480 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
481 | } |
||
482 | |||
483 | /** |
||
484 | * Mark a points log as unreversed. |
||
485 | * |
||
486 | * @since 2.1.4 |
||
487 | * @deprecated 2.4.0 |
||
488 | * |
||
489 | * @param int $log_id The ID of the log to mark as unreversed. |
||
490 | */ |
||
491 | protected function _2_1_4_mark_unreversed( $log_id ) { |
||
493 | } |
||
494 | |||
495 | /** |
||
496 | * Get all of the legacy logs grouped by post ID. |
||
497 | * |
||
498 | * @since 2.1.4 |
||
499 | * @deprecated 2.4.0 |
||
500 | * |
||
501 | * @param string[] $post_types The post types to retrieve logs for. |
||
502 | * |
||
503 | * @return array[] The logs, grouped by post ID. |
||
504 | */ |
||
505 | protected function _2_1_4_get_legacy_reactor_logs( $post_types ) { |
||
506 | |||
507 | _deprecated_function( __METHOD__, '2.4.0' ); |
||
508 | |||
509 | return array(); |
||
510 | } |
||
511 | |||
512 | /** |
||
513 | * Get the post IDs from the old points hooks logs. |
||
514 | * |
||
515 | * @since 2.1.4 |
||
516 | * @deprecated 2.4.0 |
||
517 | * |
||
518 | * @return int[] The post IDs for the points hooks logs. |
||
519 | */ |
||
520 | protected function _2_1_4_get_legacy_points_hook_post_ids() { |
||
525 | } |
||
526 | } |
||
527 | |||
528 | return 'WordPoints_Points_Un_Installer'; |
||
529 | |||
530 | // EOF |
||
531 |