| Conditions | 20 | 
| Paths | 291 | 
| Total Lines | 81 | 
| 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  | 
            ||
| 62 | function process_anchor_params() { | 
            ||
| 63 | if (  | 
            ||
| 64 | ! function_exists( 'get_current_screen' )  | 
            ||
| 65 | || is_null( \get_current_screen() )  | 
            ||
| 66 | 	) { | 
            ||
| 67 | return;  | 
            ||
| 68 | }  | 
            ||
| 69 | |||
| 70 | $current_screen = \get_current_screen();  | 
            ||
| 71 | // TODO: Replace `$current_screen->is_block_editor()` with `wp_should_load_block_editor_scripts_and_styles()` that is introduced in WP 5.6.  | 
            ||
| 72 | 	if ( method_exists( $current_screen, 'is_block_editor' ) && ! $current_screen->is_block_editor() ) { | 
            ||
| 73 | // Return early if we are not in the block editor.  | 
            ||
| 74 | return;  | 
            ||
| 75 | }  | 
            ||
| 76 | |||
| 77 | $post = get_post();  | 
            ||
| 78 | 	if ( ! $post || ! $post->ID ) { | 
            ||
| 79 | return;  | 
            ||
| 80 | }  | 
            ||
| 81 | |||
| 82 | // phpcs:disable WordPress.Security.NonceVerification.Recommended  | 
            ||
| 83 | $podcast_id = isset( $_GET['anchor_podcast'] ) ? sanitize_text_field( wp_unslash( $_GET['anchor_podcast'] ) ) : null;  | 
            ||
| 84 | $episode_id = isset( $_GET['anchor_episode'] ) ? sanitize_text_field( wp_unslash( $_GET['anchor_episode'] ) ) : null;  | 
            ||
| 85 | $spotify_show_url = isset( $_GET['spotify_show_url'] ) ? esc_url_raw( wp_unslash( $_GET['spotify_show_url'] ) ) : null;  | 
            ||
| 86 | // phpcs:enable WordPress.Security.NonceVerification.Recommended  | 
            ||
| 87 | |||
| 88 | $data = array(  | 
            ||
| 89 | 'actions' => array(),  | 
            ||
| 90 | );  | 
            ||
| 91 | |||
| 92 | 	if ( ! empty( $podcast_id ) ) { | 
            ||
| 93 | $feed = 'https://anchor.fm/s/' . $podcast_id . '/podcast/rss';  | 
            ||
| 94 | $podcast_helper = new Jetpack_Podcast_Helper( $feed );  | 
            ||
| 95 | $rss = $podcast_helper->load_feed();  | 
            ||
| 96 | 		if ( ! \is_wp_error( $rss ) ) { | 
            ||
| 97 | update_post_meta( $post->ID, 'jetpack_anchor_podcast', $podcast_id );  | 
            ||
| 98 | |||
| 99 | 			if ( ! empty( $episode_id ) ) { | 
            ||
| 100 | $track = $podcast_helper->get_track_data( $episode_id );  | 
            ||
| 101 | 				if ( ! \is_wp_error( $track ) ) { | 
            ||
| 102 | update_post_meta( $post->ID, 'jetpack_anchor_episode', $episode_id );  | 
            ||
| 103 | |||
| 104 | 					if ( 'post-new.php' === $GLOBALS['pagenow'] ) { | 
            ||
| 105 | $data['actions'][] = array(  | 
            ||
| 106 | 'set-episode-title',  | 
            ||
| 107 | array(  | 
            ||
| 108 | 'title' => $track['title'],  | 
            ||
| 109 | ),  | 
            ||
| 110 | );  | 
            ||
| 111 | }  | 
            ||
| 112 | }  | 
            ||
| 113 | }  | 
            ||
| 114 | }  | 
            ||
| 115 | }  | 
            ||
| 116 | |||
| 117 | 	if ( ! empty( $spotify_show_url ) ) { | 
            ||
| 118 | $data['spotifyShowUrl'] = $spotify_show_url;  | 
            ||
| 119 | 		if ( get_post_meta( $post->ID, 'jetpack_anchor_spotify_show', true ) !== $spotify_show_url ) { | 
            ||
| 120 | update_post_meta( $post->ID, 'jetpack_anchor_spotify_show', $spotify_show_url );  | 
            ||
| 121 | $data['actions'][] = array(  | 
            ||
| 122 | 'insert-spotify-badge',  | 
            ||
| 123 | array(  | 
            ||
| 124 | 'image' => Assets::staticize_subdomain( 'https://wordpress.com/i/spotify-badge.svg' ),  | 
            ||
| 125 | 'url' => $spotify_show_url,  | 
            ||
| 126 | ),  | 
            ||
| 127 | );  | 
            ||
| 128 | }  | 
            ||
| 129 | }  | 
            ||
| 130 | |||
| 131 | // Display an outbound link after publishing a post (only to English-speaking users since Anchor  | 
            ||
| 132 | // is English only).  | 
            ||
| 133 | if (  | 
            ||
| 134 | 'post' === get_post_type() &&  | 
            ||
| 135 | ! get_post_meta( $post->ID, 'jetpack_anchor_spotify_show', true ) &&  | 
            ||
| 136 | 0 === strpos( get_user_locale(), 'en' )  | 
            ||
| 137 | 	) { | 
            ||
| 138 | $data['actions'][] = 'show-post-publish-outbound-link';  | 
            ||
| 139 | }  | 
            ||
| 140 | |||
| 141 | wp_localize_script( 'jetpack-blocks-editor', 'Jetpack_AnchorFm', $data );  | 
            ||
| 142 | }  | 
            ||
| 143 | |||
| 146 |