| Conditions | 20 | 
| Paths | 864 | 
| Total Lines | 78 | 
| 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  | 
            ||
| 136 | function get_revue_button( $attributes ) { | 
            ||
| 137 | $classes = array( 'wp-block-button__link' );  | 
            ||
| 138 | $styles = array();  | 
            ||
| 139 | |||
| 140 | $text = get_revue_attribute( 'text', $attributes );  | 
            ||
| 141 | $has_class_name = array_key_exists( 'className', $attributes );  | 
            ||
| 142 | $has_named_text_color = array_key_exists( 'textColor', $attributes );  | 
            ||
| 143 | $has_custom_text_color = array_key_exists( 'customTextColor', $attributes );  | 
            ||
| 144 | $has_named_background_color = array_key_exists( 'backgroundColor', $attributes );  | 
            ||
| 145 | $has_custom_background_color = array_key_exists( 'customBackgroundColor', $attributes );  | 
            ||
| 146 | $has_named_gradient = array_key_exists( 'gradient', $attributes );  | 
            ||
| 147 | $has_custom_gradient = array_key_exists( 'customGradient', $attributes );  | 
            ||
| 148 | $has_border_radius = array_key_exists( 'borderRadius', $attributes );  | 
            ||
| 149 | |||
| 150 | 	if ( $has_class_name ) { | 
            ||
| 151 | $classes[] = $attributes['className'];  | 
            ||
| 152 | }  | 
            ||
| 153 | |||
| 154 | 	if ( $has_named_text_color || $has_custom_text_color ) { | 
            ||
| 155 | $classes[] = 'has-text-color';  | 
            ||
| 156 | }  | 
            ||
| 157 | 	if ( $has_named_text_color ) { | 
            ||
| 158 | $classes[] = sprintf( 'has-%s-color', $attributes['textColor'] );  | 
            ||
| 159 | 	} elseif ( $has_custom_text_color ) { | 
            ||
| 160 | $styles[] = sprintf( 'color: %s;', $attributes['customTextColor'] );  | 
            ||
| 161 | }  | 
            ||
| 162 | |||
| 163 | if (  | 
            ||
| 164 | $has_named_background_color ||  | 
            ||
| 165 | $has_custom_background_color ||  | 
            ||
| 166 | $has_named_gradient ||  | 
            ||
| 167 | $has_custom_gradient  | 
            ||
| 168 | 	) { | 
            ||
| 169 | $classes[] = 'has-background';  | 
            ||
| 170 | }  | 
            ||
| 171 | 	if ( $has_named_background_color && ! $has_custom_gradient ) { | 
            ||
| 172 | $classes[] = sprintf( 'has-%s-background-color', $attributes['backgroundColor'] );  | 
            ||
| 173 | }  | 
            ||
| 174 | 	if ( $has_named_gradient ) { | 
            ||
| 175 | $classes[] = sprintf( 'has-%s-gradient-background', $attributes['gradient'] );  | 
            ||
| 176 | 	} elseif ( $has_custom_gradient ) { | 
            ||
| 177 | $styles[] = sprintf( 'background: %s;', $attributes['customGradient'] );  | 
            ||
| 178 | }  | 
            ||
| 179 | if (  | 
            ||
| 180 | $has_custom_background_color &&  | 
            ||
| 181 | ! $has_named_background_color &&  | 
            ||
| 182 | ! $has_named_gradient &&  | 
            ||
| 183 | ! $has_custom_gradient  | 
            ||
| 184 | 	) { | 
            ||
| 185 | $styles[] = sprintf( 'background-color: %s;', $attributes['customBackgroundColor'] );  | 
            ||
| 186 | }  | 
            ||
| 187 | |||
| 188 | 	if ( $has_border_radius ) { | 
            ||
| 189 | // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison  | 
            ||
| 190 | 		if ( 0 == $attributes['borderRadius'] ) { | 
            ||
| 191 | $classes[] = 'no-border-radius';  | 
            ||
| 192 | 		} else { | 
            ||
| 193 | $styles[] = sprintf( 'border-radius: %spx;', $attributes['borderRadius'] );  | 
            ||
| 194 | }  | 
            ||
| 195 | }  | 
            ||
| 196 | |||
| 197 | ob_start();  | 
            ||
| 198 | ?>  | 
            ||
| 199 | |||
| 200 | <div class="wp-block-button">  | 
            ||
| 201 | <button  | 
            ||
| 202 | class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"  | 
            ||
| 203 | name="member[subscribe]"  | 
            ||
| 204 | style="<?php echo esc_attr( implode( ' ', $styles ) ); ?>"  | 
            ||
| 205 | type="submit"  | 
            ||
| 206 | >  | 
            ||
| 207 | <?php echo wp_kses_post( $text ); ?>  | 
            ||
| 208 | </button>  | 
            ||
| 209 | </div>  | 
            ||
| 210 | |||
| 211 | <?php  | 
            ||
| 212 | return ob_get_clean();  | 
            ||
| 213 | }  | 
            ||
| 214 | |||
| 244 |