| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Lines | 52 |
| Ratio | 100 % |
| 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 |
||
| 20 | public function get_form_defaults() { |
||
| 21 | return array( |
||
| 22 | 'id' => 0, |
||
| 23 | 'list_id' => '', |
||
| 24 | 'form_name' => '', |
||
| 25 | 'form_description' => '', |
||
| 26 | 'fields' => array(), |
||
| 27 | 'custom_styles' => '', |
||
| 28 | 'custom_template' => '', |
||
| 29 | 'redirect_user_on_submit' => 0, |
||
| 30 | 'redirect_page' => '', |
||
| 31 | 'submission_settings' => array( |
||
| 32 | 'ajax' => 1, |
||
| 33 | 'redirect_on_submission' => 0, |
||
| 34 | 'redirect_page' => 1, |
||
| 35 | 'hide_form_post_signup' => 0, |
||
| 36 | ), |
||
| 37 | 'optin_settings' => array( |
||
| 38 | 'optin' => 1, |
||
| 39 | 'update_existing_user' => 1, |
||
| 40 | 'send_update_email' => 1, |
||
| 41 | ), |
||
| 42 | 'form_settings' => array( |
||
| 43 | 'yikes-easy-mc-form-class-names' => '', |
||
| 44 | 'yikes-easy-mc-inline-form' => 0, |
||
| 45 | 'yikes-easy-mc-submit-button-type' => 'text', |
||
| 46 | 'yikes-easy-mc-submit-button-text' => __( 'Submit', 'yikes-inc-easy-mailchimp-extender' ), |
||
| 47 | 'yikes-easy-mc-submit-button-image' => '', |
||
| 48 | 'yikes-easy-mc-submit-button-classes' => '', |
||
| 49 | 'yikes-easy-mc-form-schedule' => 0, |
||
| 50 | 'yikes-easy-mc-form-restriction-start' => 0, |
||
| 51 | 'yikes-easy-mc-form-restriction-end' => 0, |
||
| 52 | 'yikes-easy-mc-form-restriction-pending-message' => sprintf( __( 'Signup is not yet open, and will be available on %s. Please come back then to signup.', 'yikes-inc-easy-mailchimp-extender' ), current_time( str_replace( '-', '/', get_option( 'date_format' ) ) ) . ' ' . __( 'at', 'yikes-inc-easy-mailchimp-extender' ) . ' ' . current_time( 'g:iA' ) ), |
||
| 53 | 'yikes-easy-mc-form-restriction-expired-message' => sprintf( __( 'This signup for this form ended on %s.', 'yikes-inc-easy-mailchimp-extender' ), date( str_replace( '-', '/', get_option( 'date_format' ) ), strtotime( current_time( str_replace( '-', '/', get_option( 'date_format' ) ) ) ) + ( 3600 * 24 ) ) . ' ' . __( 'at', 'yikes-inc-easy-mailchimp-extender' ) . ' ' . date( 'g:iA', strtotime( current_time( 'g:iA' ) ) + ( 3600 * 24 ) ) ), |
||
| 54 | 'yikes-easy-mc-form-login-required' => 0, |
||
| 55 | 'yikes-easy-mc-form-restriction-login-message' => __( 'You need to be logged in to sign up for this mailing list.', 'yikes-inc-easy-mailchimp-extender' ), |
||
| 56 | ), |
||
| 57 | 'error_messages' => array( |
||
| 58 | 'success' => '', |
||
| 59 | 'success-single-optin' => '', |
||
| 60 | 'success-resubscribed' => '', |
||
| 61 | 'general-error' => '', |
||
| 62 | 'already-subscribed' => '', |
||
| 63 | 'update-link' => '', |
||
| 64 | 'email-subject' => '', |
||
| 65 | ), |
||
| 66 | 'custom_notifications' => '', |
||
| 67 | 'impressions' => 0, |
||
| 68 | 'submissions' => 0, |
||
| 69 | 'custom_fields' => array(), |
||
| 70 | ); |
||
| 71 | } |
||
| 72 | |||
| 88 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.