| Conditions | 1 |
| Paths | 1 |
| Total Lines | 76 |
| Code Lines | 60 |
| 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 |
||
| 37 | public function define_fields() { |
||
| 38 | |||
| 39 | return array( |
||
| 40 | array( |
||
| 41 | 'type' => 'container', |
||
| 42 | 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
||
| 43 | ), |
||
| 44 | array( |
||
| 45 | 'type' => 'textbox', |
||
| 46 | 'name' => 'ids', |
||
| 47 | 'label' => esc_attr__( 'Form IDs:', 'give' ), |
||
| 48 | 'tooltip' => esc_attr__( 'Enter a comma-separated list of form IDs. If empty, all published forms are displayed.', 'give' ), |
||
| 49 | 'placeholder' => esc_html__( 'All Forms', 'give' ) |
||
| 50 | ), |
||
| 51 | array( |
||
| 52 | 'type' => 'listbox', |
||
| 53 | 'name' => 'columns', |
||
| 54 | 'label' => esc_attr__( 'Columns:', 'give' ), |
||
| 55 | 'tooltip' => esc_attr__( 'Sets the number of donations per row.', 'give' ), |
||
| 56 | 'options' => array( |
||
| 57 | '1' => esc_html__( '1', 'give' ), |
||
| 58 | '2' => esc_html__( '2', 'give' ), |
||
| 59 | '3' => esc_html__( '3', 'give' ), |
||
| 60 | '4' => esc_html__( '4', 'give' ), |
||
| 61 | ), |
||
| 62 | 'placeholder' => esc_html__( 'Best Fit', 'give' ) |
||
| 63 | ), |
||
| 64 | array( |
||
| 65 | 'type' => 'listbox', |
||
| 66 | 'name' => 'show_goal', |
||
| 67 | 'label' => esc_attr__( 'Show Goal:', 'give' ), |
||
| 68 | 'tooltip' => __( 'Do you want to display the goal\'s progress bar?', 'give' ), |
||
| 69 | 'options' => array( |
||
| 70 | 'true' => esc_html__( 'Show', 'give' ), |
||
| 71 | 'false' => esc_html__( 'Hide', 'give' ), |
||
| 72 | ), |
||
| 73 | ), |
||
| 74 | array( |
||
| 75 | 'type' => 'listbox', |
||
| 76 | 'name' => 'show_excerpt', |
||
| 77 | 'label' => esc_attr__( 'Show Excerpt:', 'give' ), |
||
| 78 | 'tooltip' => esc_attr__( 'Do you want to display the excerpt?', 'give' ), |
||
| 79 | 'options' => array( |
||
| 80 | 'true' => esc_html__( 'Show', 'give' ), |
||
| 81 | 'false' => esc_html__( 'Hide', 'give' ), |
||
| 82 | ), |
||
| 83 | ), |
||
| 84 | array( |
||
| 85 | 'type' => 'listbox', |
||
| 86 | 'name' => 'show_featured_image', |
||
| 87 | 'label' => esc_attr__( 'Show Featured Image:', 'give' ), |
||
| 88 | 'tooltip' => esc_attr__( 'Do you want to display the featured image?', 'give' ), |
||
| 89 | 'options' => array( |
||
| 90 | 'true' => esc_html__( 'Show', 'give' ), |
||
| 91 | 'false' => esc_html__( 'Hide', 'give' ), |
||
| 92 | ), |
||
| 93 | ), |
||
| 94 | array( |
||
| 95 | 'type' => 'listbox', |
||
| 96 | 'name' => 'display_style', |
||
| 97 | 'label' => esc_attr__( 'Display Style:', 'give' ), |
||
| 98 | 'tooltip' => esc_attr__( 'Show form as modal window or redirect to a new page?', 'give' ), |
||
| 99 | 'options' => array( |
||
| 100 | 'redirect' => esc_html__( 'Redirect', 'give' ), |
||
| 101 | 'modal_reveal' => esc_html__( 'Modal', 'give' ), |
||
| 102 | ), |
||
| 103 | ), |
||
| 104 | array( |
||
| 105 | 'type' => 'textbox', |
||
| 106 | 'name' => 'forms_per_page', |
||
| 107 | 'label' => esc_attr__( 'Forms Per Page:', 'give' ), |
||
| 108 | 'tooltip' => esc_attr__( 'Sets the number of donations form per row.', 'give' ), |
||
| 109 | 'value' => 12, |
||
| 110 | ), |
||
| 111 | ); |
||
| 112 | } |
||
| 113 | } |
||
| 116 |
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.