| Conditions | 1 |
| Paths | 1 |
| Total Lines | 75 |
| Code Lines | 56 |
| 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 |
||
| 20 | protected function styleConfig(): array |
||
| 21 | { |
||
| 22 | return [ |
||
| 23 | 'spacing' => [ |
||
| 24 | 'default' => [ |
||
| 25 | 'unit' => 'em', |
||
| 26 | 'size' => 0.75, |
||
| 27 | ], |
||
| 28 | 'is_responsive' => true, |
||
| 29 | 'label' => esc_html_x('Field Spacing', 'admin-text', 'site-reviews'), |
||
| 30 | 'range' => [ |
||
| 31 | 'em' => [ |
||
| 32 | 'min' => 0, |
||
| 33 | 'max' => 2, |
||
| 34 | 'step' => 0.125, |
||
| 35 | ], |
||
| 36 | ], |
||
| 37 | 'selectors' => [ |
||
| 38 | '{{WRAPPER}} .glsr-review-form' => '--glsr-gap-md: {{SIZE}}{{UNIT}};', |
||
| 39 | '{{WRAPPER}} .elementor-form .elementor-form-fields-wrapper .glsr-field' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
||
| 40 | ], |
||
| 41 | 'size_units' => ['em', 'custom'], |
||
| 42 | 'type' => Controls_Manager::SLIDER, |
||
| 43 | ], |
||
| 44 | 'rating_color' => [ |
||
| 45 | 'global' => [ |
||
| 46 | 'default' => '', |
||
| 47 | ], |
||
| 48 | 'label' => esc_html_x('Color', 'admin-text', 'site-reviews'), |
||
| 49 | 'selectors' => [ |
||
| 50 | '{{WRAPPER}} .glsr:not([data-theme]) .glsr-field:not(.glsr-field-is-invalid) .glsr-star-rating--stars > span' => 'background: {{VALUE}} !important;', |
||
| 51 | '{{WRAPPER}} .glsr:not([data-theme]) .glsr-field-is-invalid .glsr-star-rating--stars > span.gl-active' => 'background: {{VALUE}} !important;', |
||
| 52 | ], |
||
| 53 | 'type' => Controls_Manager::COLOR, |
||
| 54 | ], |
||
| 55 | 'rating_size' => [ |
||
| 56 | 'default' => [ |
||
| 57 | 'unit' => 'em', |
||
| 58 | 'size' => 2, |
||
| 59 | ], |
||
| 60 | 'is_responsive' => true, |
||
| 61 | 'label' => esc_html_x('Star Size', 'admin-text', 'site-reviews'), |
||
| 62 | 'range' => [ |
||
| 63 | 'em' => [ |
||
| 64 | 'min' => 1, |
||
| 65 | 'max' => 3, |
||
| 66 | 'step' => 0.125, |
||
| 67 | ], |
||
| 68 | ], |
||
| 69 | 'selectors' => [ |
||
| 70 | '{{WRAPPER}} form.glsr-form .glsr-field-rating' => '--glsr-form-star: {{SIZE}}{{UNIT}};', |
||
| 71 | '{{WRAPPER}} .glsr[data-theme] .glsr-field-rating [data-stars]' => 'font-size: initial;', |
||
| 72 | '{{WRAPPER}} .glsr[data-theme] .glsr-field-rating [data-stars] > span' => 'font-size: initial; height: var(--glsr-form-star); width: var(--glsr-form-star);', |
||
| 73 | ], |
||
| 74 | 'size_units' => ['em', 'custom'], |
||
| 75 | 'type' => Controls_Manager::SLIDER, |
||
| 76 | ], |
||
| 77 | 'rating_spacing' => [ |
||
| 78 | 'default' => [ |
||
| 79 | 'unit' => 'px', |
||
| 80 | 'size' => 2, |
||
| 81 | ], |
||
| 82 | 'is_responsive' => true, |
||
| 83 | 'label' => esc_html_x('Star Spacing', 'admin-text', 'site-reviews'), |
||
| 84 | 'range' => [ |
||
| 85 | 'px' => [ |
||
| 86 | 'min' => 0, |
||
| 87 | 'max' => 10, |
||
| 88 | ], |
||
| 89 | ], |
||
| 90 | 'selectors' => [ |
||
| 91 | '{{WRAPPER}} form.glsr-form .glsr-field-rating span[data-rating]' => 'column-gap: {{SIZE}}{{UNIT}};', |
||
| 92 | ], |
||
| 93 | 'size_units' => ['px', 'custom'], |
||
| 94 | 'type' => Controls_Manager::SLIDER, |
||
| 95 | ], |
||
| 99 |