| Conditions | 22 |
| Paths | > 20000 |
| Total Lines | 27 |
| 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 |
||
| 66 | public function render_block( $attributes, $content ) { |
||
| 67 | |||
| 68 | if ( ! isset( $attributes['form_id'] ) ) { |
||
| 69 | return; |
||
| 70 | } |
||
| 71 | |||
| 72 | $shortcode_attributes = array( |
||
| 73 | 'form' => $attributes['form_id'], |
||
| 74 | 'submit' => isset( $attributes['submit_button_text'] ) && ! empty( $attributes['submit_button_text'] ) ? $attributes['submit_button_text'] : '', |
||
| 75 | 'title' => isset( $attributes['show_title'] ) && true === $attributes['show_title'] ? '1' : '0', |
||
| 76 | 'custom_title' => isset( $attributes['form_title'] ) ? $attributes['form_title'] : '', |
||
| 77 | 'description' => isset( $attributes['show_description'] ) && true === $attributes['show_description'] ? '1' : '0', |
||
| 78 | 'custom_description' => isset( $attributes['form_description'] ) ? $attributes['form_description'] : '', |
||
| 79 | 'ajax' => isset( $attributes['is_ajax'] ) && true === $attributes['is_ajax'] ? '1' : '0', |
||
| 80 | 'recaptcha' => isset( $attributes['recaptcha'] ) && false === $attributes['recaptcha'] ? '0' : '', |
||
| 81 | 'recaptcha_lang' => isset( $attributes['recaptcha_lang'] ) ? $attributes['recaptcha_lang'] : '', |
||
| 82 | 'recaptcha_type' => isset( $attributes['recaptcha_type'] ) ? $attributes['recaptcha_type'] : '', |
||
| 83 | 'recaptcha_theme' => isset( $attributes['recaptcha_theme'] ) ? $attributes['recaptcha_theme'] : '', |
||
| 84 | 'recaptcha_size' => isset( $attributes['recaptcha_size'] ) ? $attributes['recaptcha_size'] : '', |
||
| 85 | 'recaptcha_data_callback' => isset( $attributes['recaptcha_verify_callback'] ) ? $attributes['recaptcha_verify_callback'] : '', |
||
| 86 | 'recaptcha_expired_callback' => isset( $attributes['recaptcha_expired_callback'] ) ? $attributes['recaptcha_expired_callback'] : '', |
||
| 87 | 'inline' => isset( $attributes['inline'] ) && true === $attributes['inline'] ? '1' : '0', |
||
| 88 | ); |
||
| 89 | |||
| 90 | // We want to run process_mailchimp_shortcode() but we need to return the plaintext shortcode or Gutenberg will autop() the shortcode content. |
||
| 91 | return '[yikes-mailchimp form="' . $shortcode_attributes['form'] . '" submit="' . $shortcode_attributes['submit'] . '" title="' . $shortcode_attributes['title'] . '" custom_title="' . $shortcode_attributes['custom_title'] . '" description="' . $shortcode_attributes['description'] . '" custom_description="' . $shortcode_attributes['custom_description'] . '" ajax="' . $shortcode_attributes['ajax'] . '" recaptcha="' . $shortcode_attributes['recaptcha'] . '" recaptcha_lang="' . $shortcode_attributes['recaptcha_lang'] . '" recaptcha_type="' . $shortcode_attributes['recaptcha_type'] . '" recaptcha_theme="' . $shortcode_attributes['recaptcha_theme'] . '" recaptcha_size="' . $shortcode_attributes['recaptcha_size'] . '" recaptcha_data_callback="' . $shortcode_attributes['recaptcha_data_callback'] . '" recaptcha_expired_callback="' . $shortcode_attributes['recaptcha_expired_callback'] . '" inline="' . $shortcode_attributes['inline'] . '"]'; |
||
| 92 | } |
||
| 93 | } |
||
| 94 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.