| Conditions | 2 |
| Paths | 2 |
| Total Lines | 133 |
| Code Lines | 104 |
| 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 |
||
| 12 | public function options(): array |
||
| 13 | { |
||
| 14 | $options = [ |
||
| 15 | 'limit_group' => [ |
||
| 16 | 'type' => 'group', |
||
| 17 | 'heading' => esc_html_x('Limit Reviews By', 'admin-text', 'site-reviews'), |
||
| 18 | 'options' => [ |
||
| 19 | 'assigned_posts' => [ |
||
| 20 | 'type' => 'select', |
||
| 21 | 'heading' => esc_html_x('Limit Reviews by Assigned Pages', 'admin-text', 'site-reviews'), |
||
| 22 | 'full_width' => true, |
||
| 23 | 'config' => [ |
||
| 24 | 'multiple' => true, |
||
| 25 | 'placeholder' => esc_html_x('Select...', 'admin-text', 'site-reviews'), |
||
| 26 | 'postSelect' => 'assigned_posts_query', |
||
| 27 | ], |
||
| 28 | ], |
||
| 29 | 'assigned_terms' => [ |
||
| 30 | 'type' => 'select', |
||
| 31 | 'heading' => esc_html_x('Limit Reviews by Categories', 'admin-text', 'site-reviews'), |
||
| 32 | 'default' => '', |
||
| 33 | 'full_width' => true, |
||
| 34 | 'config' => [ |
||
| 35 | 'multiple' => true, |
||
| 36 | 'placeholder' => esc_html_x('Select...', 'admin-text', 'site-reviews'), |
||
| 37 | 'termSelect' => [ |
||
| 38 | 'taxonomies' => glsr()->taxonomy, |
||
| 39 | ], |
||
| 40 | ], |
||
| 41 | ], |
||
| 42 | 'assigned_users' => [ |
||
| 43 | 'type' => 'select', |
||
| 44 | 'heading' => esc_html_x('Limit Reviews by Assigned Users', 'admin-text', 'site-reviews'), |
||
| 45 | 'default' => '', |
||
| 46 | 'full_width' => true, |
||
| 47 | 'config' => [ |
||
| 48 | 'multiple' => true, |
||
| 49 | 'placeholder' => esc_html_x('Select...', 'admin-text', 'site-reviews'), |
||
| 50 | 'postSelect' => 'assigned_users_query', |
||
| 51 | ], |
||
| 52 | ], |
||
| 53 | 'terms' => [ |
||
| 54 | 'type' => 'select', |
||
| 55 | 'heading' => esc_html_x('Limit Reviews by Accepted Terms', 'admin-text', 'site-reviews'), |
||
| 56 | 'default' => '', |
||
| 57 | 'full_width' => true, |
||
| 58 | 'options' => [ |
||
| 59 | '' => esc_html_x('Select...', 'admin-text', 'site-reviews'), |
||
| 60 | 'true' => esc_html_x('Terms were accepted', 'admin-text', 'site-reviews'), |
||
| 61 | 'false' => esc_html_x('Terms were not accepted', 'admin-text', 'site-reviews'), |
||
| 62 | ], |
||
| 63 | ], |
||
| 64 | ], |
||
| 65 | ], |
||
| 66 | 'display_group' => [ |
||
| 67 | 'type' => 'group', |
||
| 68 | 'heading' => esc_html_x('Display Options', 'admin-text', 'site-reviews'), |
||
| 69 | 'options' => [ |
||
| 70 | 'pagination' => [ |
||
| 71 | 'type' => 'select', |
||
| 72 | 'heading' => esc_html_x('Pagination Type', 'admin-text', 'site-reviews'), |
||
| 73 | 'default' => '', |
||
| 74 | 'full_width' => true, |
||
| 75 | 'options' => [ |
||
| 76 | '' => esc_attr_x('No Pagination', 'admin-text', 'site-reviews'), |
||
| 77 | 'loadmore' => esc_attr_x('Load More Button', 'admin-text', 'site-reviews'), |
||
| 78 | 'ajax' => esc_attr_x('Pagination (AJAX)', 'admin-text', 'site-reviews'), |
||
| 79 | 'true' => esc_attr_x('Pagination (with page reload)', 'admin-text', 'site-reviews'), |
||
| 80 | ], |
||
| 81 | ], |
||
| 82 | 'display' => [ |
||
| 83 | 'type' => 'slider', |
||
| 84 | 'heading' => esc_html_x('Reviews Per Page', 'admin-text', 'site-reviews'), |
||
| 85 | 'default' => 10, |
||
| 86 | 'max' => 50, |
||
| 87 | 'min' => 1, |
||
| 88 | ], |
||
| 89 | 'rating' => [ |
||
| 90 | 'type' => 'slider', |
||
| 91 | 'heading' => esc_html_x('Minimum Rating', 'admin-text', 'site-reviews'), |
||
| 92 | 'default' => 0, |
||
| 93 | 'max' => Cast::toInt(glsr()->constant('MAX_RATING', Rating::class)), |
||
| 94 | 'min' => Cast::toInt(glsr()->constant('MIN_RATING', Rating::class)), |
||
| 95 | ], |
||
| 96 | 'schema' => [ |
||
| 97 | 'type' => 'checkbox', |
||
| 98 | 'heading' => esc_html_x('Enable the schema?', 'admin-text', 'site-reviews'), |
||
| 99 | 'description' => esc_html_x('The schema should only be enabled once per page.', 'admin-text', 'site-reviews'), |
||
| 100 | ], |
||
| 101 | ], |
||
| 102 | ], |
||
| 103 | 'hide_group' => [ |
||
| 104 | 'type' => 'group', |
||
| 105 | 'heading' => esc_html_x('Hide Options', 'admin-text', 'site-reviews'), |
||
| 106 | 'options' => $this->hideOptions(), |
||
| 107 | ], |
||
| 108 | 'advanced_group' => [ |
||
| 109 | 'type' => 'group', |
||
| 110 | 'heading' => esc_html_x('Advanced', 'admin-text', 'site-reviews'), |
||
| 111 | 'options' => [ |
||
| 112 | 'id' => [ |
||
| 113 | 'type' => 'textfield', |
||
| 114 | 'heading' => esc_html_x('Custom ID', 'admin-text', 'site-reviews'), |
||
| 115 | 'description' => esc_html_x('This should be a unique value.', 'admin-text', 'site-reviews'), |
||
| 116 | 'full_width' => true, |
||
| 117 | ], |
||
| 118 | 'class' => [ |
||
| 119 | 'type' => 'textfield', |
||
| 120 | 'heading' => esc_html_x('Additional CSS classes', 'admin-text', 'site-reviews'), |
||
| 121 | 'description' => esc_html_x('Separate multiple classes with spaces.', 'admin-text', 'site-reviews'), |
||
| 122 | 'full_width' => true, |
||
| 123 | ], |
||
| 124 | 'visibility' => [ |
||
| 125 | 'type' => 'select', |
||
| 126 | 'heading' => esc_html_x('Visibility', 'admin-text', 'site-reviews'), |
||
| 127 | 'default' => '', |
||
| 128 | 'options' => [ |
||
| 129 | '' => esc_html_x('Visible', 'admin-text', 'site-reviews'), |
||
| 130 | 'hidden' => esc_html_x('Hidden', 'admin-text', 'site-reviews'), |
||
| 131 | 'hide-for-medium' => esc_html_x('Only for Desktop', 'admin-text', 'site-reviews'), |
||
| 132 | 'show-for-small' => esc_html_x('Only for Mobile', 'admin-text', 'site-reviews'), |
||
| 133 | 'show-for-medium hide-for-small' => esc_html_x('Only for Tablet', 'admin-text', 'site-reviews'), |
||
| 134 | 'show-for-medium' => esc_html_x('Hide for Desktop', 'admin-text', 'site-reviews'), |
||
| 135 | 'hide-for-small' => esc_html_x('Hide for Mobile', 'admin-text', 'site-reviews'), |
||
| 136 | ], |
||
| 137 | ], |
||
| 138 | ], |
||
| 139 | ], |
||
| 140 | ]; |
||
| 141 | if ($types = $this->typeOptions()) { |
||
| 142 | $options['limit_group']['options']['type'] = $types; |
||
| 143 | } |
||
| 144 | return $options; |
||
| 145 | } |
||
| 162 |