Conditions | 9 |
Paths | 17 |
Total Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 |
||
168 | static function admin_page_load() { |
||
169 | if ( isset( $_GET['action'] ) ) { |
||
170 | if ( isset( $_GET['service'] ) ) { |
||
171 | $service_name = $_GET['service']; |
||
172 | } |
||
173 | |||
174 | switch ( $_GET['action'] ) { |
||
175 | |||
176 | case 'request': |
||
177 | check_admin_referer( 'keyring-request', 'kr_nonce' ); |
||
178 | check_admin_referer( "keyring-request-$service_name", 'nonce' ); |
||
179 | |||
180 | $verification = ( new Secrets() )->generate( 'publicize' ); |
||
181 | if ( ! $verification ) { |
||
182 | $url = Jetpack::admin_url( 'jetpack#/settings' ); |
||
183 | wp_die( sprintf( __( "Jetpack is not connected. Please connect Jetpack by visiting <a href='%s'>Settings</a>.", 'jetpack' ), $url ) ); |
||
184 | |||
185 | } |
||
186 | $stats_options = get_option( 'stats_options' ); |
||
187 | $wpcom_blog_id = Jetpack_Options::get_option( 'id' ); |
||
188 | $wpcom_blog_id = ! empty( $wpcom_blog_id ) ? $wpcom_blog_id : $stats_options['blog_id']; |
||
189 | |||
190 | $user = wp_get_current_user(); |
||
191 | $redirect = Jetpack_Keyring_Service_Helper::api_url( $service_name, urlencode_deep( array( |
||
192 | 'action' => 'request', |
||
193 | 'redirect_uri' => add_query_arg( array( 'action' => 'done' ), menu_page_url( 'sharing', false ) ), |
||
194 | 'for' => 'publicize', |
||
195 | // required flag that says this connection is intended for publicize |
||
196 | 'siteurl' => site_url(), |
||
197 | 'state' => $user->ID, |
||
198 | 'blog_id' => $wpcom_blog_id, |
||
199 | 'secret_1' => $verification['secret_1'], |
||
200 | 'secret_2' => $verification['secret_2'], |
||
201 | 'eol' => $verification['exp'], |
||
202 | ) ) ); |
||
203 | wp_redirect( $redirect ); |
||
204 | exit; |
||
205 | break; |
||
206 | |||
207 | case 'completed': |
||
208 | $xml = new Jetpack_IXR_Client(); |
||
209 | $xml->query( 'jetpack.fetchPublicizeConnections' ); |
||
210 | |||
211 | if ( ! $xml->isError() ) { |
||
212 | $response = $xml->getResponse(); |
||
213 | Jetpack_Options::update_option( 'publicize_connections', $response ); |
||
214 | } |
||
215 | |||
216 | break; |
||
217 | |||
218 | case 'delete': |
||
219 | $id = $_GET['id']; |
||
220 | |||
221 | check_admin_referer( 'keyring-request', 'kr_nonce' ); |
||
222 | check_admin_referer( "keyring-request-$service_name", 'nonce' ); |
||
223 | |||
224 | Jetpack_Keyring_Service_Helper::disconnect( $service_name, $id ); |
||
225 | |||
226 | do_action( 'connection_disconnected', $service_name ); |
||
227 | break; |
||
228 | } |
||
229 | } |
||
230 | } |
||
231 | |||
247 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.