| Conditions | 1 |
| Paths | 1 |
| Total Lines | 78 |
| Code Lines | 63 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 21 | public static function vcShortcodeSettings(): array |
||
| 22 | { |
||
| 23 | return [ |
||
| 24 | 'assigned_posts' => [ |
||
| 25 | 'type' => 'autocomplete', |
||
| 26 | 'heading' => esc_html_x('Limit Reviews by Assigned Pages', 'admin-text', 'site-reviews'), |
||
| 27 | 'param_name' => 'assigned_posts', |
||
| 28 | 'settings' => [ |
||
| 29 | 'multiple' => true, |
||
| 30 | 'sortable' => true, |
||
| 31 | ], |
||
| 32 | ], |
||
| 33 | 'assigned_terms' => [ |
||
| 34 | 'type' => 'autocomplete', |
||
| 35 | 'heading' => esc_html_x('Limit Reviews by Assigned Categories', 'admin-text', 'site-reviews'), |
||
| 36 | 'param_name' => 'assigned_terms', |
||
| 37 | 'settings' => [ |
||
| 38 | 'multiple' => true, |
||
| 39 | 'sortable' => true, |
||
| 40 | ], |
||
| 41 | ], |
||
| 42 | 'assigned_users' => [ |
||
| 43 | 'type' => 'autocomplete', |
||
| 44 | 'heading' => esc_html_x('Limit Reviews by Assigned Users', 'admin-text', 'site-reviews'), |
||
| 45 | 'param_name' => 'assigned_users', |
||
| 46 | 'settings' => [ |
||
| 47 | 'multiple' => true, |
||
| 48 | 'sortable' => true, |
||
| 49 | ], |
||
| 50 | ], |
||
| 51 | 'type' => static::vcTypeOptions(), |
||
| 52 | 'terms' => [ |
||
| 53 | 'type' => 'dropdown', |
||
| 54 | 'heading' => esc_html_x('Limit Reviews by Accepted Terms', 'admin-text', 'site-reviews'), |
||
| 55 | 'param_name' => 'terms', |
||
| 56 | 'std' => '', |
||
| 57 | 'value' => [ |
||
| 58 | esc_html_x('Select Terms...', 'admin-text', 'site-reviews') => '', |
||
| 59 | esc_html_x('Terms were accepted', 'admin-text', 'site-reviews') => 'true', |
||
| 60 | esc_html_x('Terms were not accepted', 'admin-text', 'site-reviews') => 'false', |
||
| 61 | ], |
||
| 62 | ], |
||
| 63 | 'rating' => [ |
||
| 64 | 'type' => 'glsr_type_range', |
||
| 65 | 'heading' => esc_html_x('Minimum Rating', 'admin-text', 'site-reviews'), |
||
| 66 | 'max' => Cast::toInt(glsr()->constant('MAX_RATING', Rating::class)), |
||
| 67 | 'min' => Cast::toInt(glsr()->constant('MIN_RATING', Rating::class)), |
||
| 68 | 'param_name' => 'rating', |
||
| 69 | 'std' => 0, |
||
| 70 | ], |
||
| 71 | 'schema' => [ |
||
| 72 | 'type' => 'checkbox', |
||
| 73 | 'heading' => esc_html_x('Enable the schema?', 'admin-text', 'site-reviews'), |
||
| 74 | 'description' => esc_html_x('The schema should only be enabled once on your page.', 'admin-text', 'site-reviews'), |
||
| 75 | 'param_name' => 'schema', |
||
| 76 | 'value' => [ |
||
| 77 | esc_html_x('Yes', 'admin-text', 'site-reviews') => 'true', |
||
| 78 | ], |
||
| 79 | ], |
||
| 80 | 'hide' => [ |
||
| 81 | 'type' => 'checkbox', |
||
| 82 | 'heading' => esc_html__('Hide Options', 'site-reviews'), |
||
| 83 | 'param_name' => 'hide', |
||
| 84 | 'value' => array_flip(static::vcShortcode()->getHideOptions()), |
||
| 85 | ], |
||
| 86 | 'id' => [ |
||
| 87 | 'type' => 'textfield', |
||
| 88 | 'heading' => esc_html_x('Custom ID', 'admin-text', 'site-reviews'), |
||
| 89 | 'description' => esc_html_x('This should be a unique value.', 'admin-text', 'site-reviews'), |
||
| 90 | 'param_name' => 'id', |
||
| 91 | 'group' => esc_html_x('Advanced', 'admin-text', 'site-reviews'), |
||
| 92 | ], |
||
| 93 | 'class' => [ |
||
| 94 | 'type' => 'textfield', |
||
| 95 | 'heading' => esc_html_x('Additional CSS classes', 'admin-text', 'site-reviews'), |
||
| 96 | 'description' => esc_html_x('Separate multiple classes with spaces.', 'admin-text', 'site-reviews'), |
||
| 97 | 'param_name' => 'class', |
||
| 98 | 'group' => esc_html_x('Advanced', 'admin-text', 'site-reviews'), |
||
| 99 | ], |
||
| 103 |