Conditions | 7 |
Paths | 6 |
Total Lines | 51 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 8 | ||
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 |
||
38 | function start( $modules = null ) { |
||
39 | if( ! $this->should_start_full_sync() ) { |
||
40 | return false; |
||
41 | } |
||
42 | |||
43 | // ensure listener is loaded so we can guarantee full sync actions are enqueued |
||
44 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php'; |
||
45 | Jetpack_Sync_Listener::getInstance(); |
||
46 | |||
47 | /** |
||
48 | * Fires when a full sync begins. This action is serialized |
||
49 | * and sent to the server so that it knows a full sync is coming. |
||
50 | * |
||
51 | * @since 4.2.0 |
||
52 | */ |
||
53 | do_action( 'jetpack_full_sync_start' ); |
||
54 | $this->set_status_queuing_started(); |
||
55 | |||
56 | foreach( Jetpack_Sync_Modules::get_modules() as $module ) { |
||
57 | $module_name = $module->name(); |
||
58 | if ( is_array( $modules ) && ! isset( $modules[ $module_name ] ) ) { |
||
59 | continue; |
||
60 | } |
||
61 | |||
62 | $items_enqueued = $module->enqueue_full_sync_actions(); |
||
63 | if ( $items_enqueued !== 0 ) { |
||
64 | $status = $this->get_status(); |
||
65 | |||
66 | if ( ! isset( $status['queue'][ $module_name ] ) ) { |
||
67 | $status['queue'][ $module_name ] = 0; |
||
68 | } |
||
69 | |||
70 | $status['queue'][ $module_name ] += $items_enqueued; |
||
71 | } |
||
72 | $this->update_status( $status ); |
||
73 | } |
||
74 | |||
75 | $this->set_status_queuing_finished(); |
||
76 | |||
77 | $store = new Jetpack_Sync_WP_Replicastore(); |
||
78 | |||
79 | /** |
||
80 | * Fires when a full sync ends. This action is serialized |
||
81 | * and sent to the server with checksums so that we can confirm the |
||
82 | * sync was successful. |
||
83 | * |
||
84 | * @since 4.2.0 |
||
85 | */ |
||
86 | do_action( 'jetpack_full_sync_end', $store->checksum_all() ); |
||
87 | return true; |
||
88 | } |
||
89 | |||
173 |
This check marks private properties in classes that are never used. Those properties can be removed.