| Conditions | 10 |
| Paths | 160 |
| Total Lines | 34 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 65 | public function transformSelect(): void |
||
| 66 | { |
||
| 67 | if ('assigned_posts' === $this->name) { |
||
| 68 | $this->args['placeholder'] = esc_html_x('Search Pages...', 'admin-text', 'site-reviews'); |
||
| 69 | } |
||
| 70 | if ('assigned_terms' === $this->name) { |
||
| 71 | $this->args['placeholder'] = esc_html_x('Search Categories...', 'admin-text', 'site-reviews'); |
||
| 72 | } |
||
| 73 | if ('assigned_users' === $this->name) { |
||
| 74 | $this->args['placeholder'] = esc_html_x('Search Users...', 'admin-text', 'site-reviews'); |
||
| 75 | } |
||
| 76 | if ('author' === $this->name) { |
||
| 77 | $this->args['placeholder'] = esc_html_x('Search User...', 'admin-text', 'site-reviews'); |
||
| 78 | } |
||
| 79 | if ('post_id' === $this->name) { |
||
| 80 | $this->args['placeholder'] = esc_html_x('Search Review...', 'admin-text', 'site-reviews'); |
||
| 81 | } |
||
| 82 | if (!empty($this->args['options'])) { |
||
| 83 | $options = $this->args['options']; |
||
| 84 | if (!array_key_exists('', $options)) { |
||
| 85 | $placeholder = $this->args['placeholder'] ?? esc_html_x('Select...', 'admin-text', 'site-reviews'); |
||
| 86 | $options = ['' => $placeholder] + $options; |
||
| 87 | } |
||
| 88 | $this->args['value'] = $options; |
||
| 89 | } elseif (!isset($this->args['options'])) { |
||
| 90 | $this->args['ajax'] = glsr()->prefix.'fusion_search_query'; |
||
| 91 | $this->args['ajax_params'] = [ |
||
| 92 | 'option' => $this->name, |
||
| 93 | 'shortcode' => $this->shortcode, |
||
| 94 | ]; |
||
| 95 | $this->args['placeholder'] ??= esc_html_x('Search...', 'admin-text', 'site-reviews'); |
||
| 96 | $this->args['type'] = 'ajax_select'; |
||
| 97 | if (!($this->args['multiple'] ?? false)) { |
||
| 98 | $this->args['max_input'] = 1; |
||
| 99 | } |
||
| 116 |