Conditions | 7 |
Paths | 6 |
Total Lines | 52 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 9 | ||
Bugs | 1 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
36 | function start( $modules = null ) { |
||
37 | if ( ! $this->should_start_full_sync() ) { |
||
38 | return false; |
||
39 | } |
||
40 | |||
41 | // ensure listener is loaded so we can guarantee full sync actions are enqueued |
||
42 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php'; |
||
43 | Jetpack_Sync_Listener::get_instance(); |
||
44 | |||
45 | /** |
||
46 | * Fires when a full sync begins. This action is serialized |
||
47 | * and sent to the server so that it knows a full sync is coming. |
||
48 | * |
||
49 | * @since 4.2.0 |
||
50 | */ |
||
51 | do_action( 'jetpack_full_sync_start' ); |
||
52 | $this->set_status_queuing_started(); |
||
53 | |||
54 | foreach ( Jetpack_Sync_Modules::get_modules() as $module ) { |
||
55 | $module_name = $module->name(); |
||
56 | if ( is_array( $modules ) && ! in_array( $module_name, $modules ) ) { |
||
57 | continue; |
||
58 | } |
||
59 | |||
60 | $items_enqueued = $module->enqueue_full_sync_actions(); |
||
61 | if ( $items_enqueued !== 0 ) { |
||
62 | $status = $this->get_status(); |
||
63 | |||
64 | if ( ! isset( $status['queue'][ $module_name ] ) ) { |
||
65 | $status['queue'][ $module_name ] = 0; |
||
66 | } |
||
67 | |||
68 | $status['queue'][ $module_name ] += $items_enqueued; |
||
69 | $this->update_status( $status ); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | $this->set_status_queuing_finished(); |
||
74 | |||
75 | $store = new Jetpack_Sync_WP_Replicastore(); |
||
76 | |||
77 | /** |
||
78 | * Fires when a full sync ends. This action is serialized |
||
79 | * and sent to the server with checksums so that we can confirm the |
||
80 | * sync was successful. |
||
81 | * |
||
82 | * @since 4.2.0 |
||
83 | */ |
||
84 | do_action( 'jetpack_full_sync_end', $store->checksum_all() ); |
||
85 | |||
86 | return true; |
||
87 | } |
||
88 | |||
172 |