Test Failed
Push — develop ( 55c79d...550055 )
by Paul
09:38
created

ElementorSiteReviews::styleConfig()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 79
Code Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 59
c 1
b 0
f 0
dl 0
loc 79
rs 8.8945
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Elementor;
4
5
use Elementor\Controls_Manager;
6
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsShortcode;
7
8
class ElementorSiteReviews extends ElementorWidget
9
{
10
    public function get_icon(): string
11
    {
12
        return 'eicon-glsr-reviews';
13
    }
14
15
    public static function shortcodeClass(): string
16
    {
17
        return SiteReviewsShortcode::class;
18
    }
19
20
    protected function styleConfig(): array
21
    {
22
        return [
23
            'alignment' => [
24
                'default' => 'start',
25
                'is_responsive' => true,
26
                'label' => esc_html_x('Alignment', 'admin-text', 'site-reviews'),
27
                'options' => [
28
                    'start' => [
29
                        'title' => esc_html_x('Start', 'admin-text', 'site-reviews'),
30
                        'icon' => 'eicon-flex eicon-align-start-h',
31
                    ],
32
                    'center' => [
33
                        'title' => esc_html_x('Center', 'admin-text', 'site-reviews'),
34
                        'icon' => 'eicon-flex eicon-align-center-h',
35
                    ],
36
                    'end' => [
37
                        'title' => esc_html_x('End', 'admin-text', 'site-reviews'),
38
                        'icon' => 'eicon-flex eicon-align-end-h',
39
                    ],
40
                ],
41
                'selectors' => [
42
                    '{{WRAPPER}} .glsr:not([data-theme]) .glsr-review' => 'text-align: {{VALUE}}; justify-content: {{VALUE}};',
43
                    '{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-review-actions' => 'justify-content: {{VALUE}};',
44
                    '{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-review-date' => 'flex: inherit;',
45
                ],
46
                'type' => Controls_Manager::CHOOSE,
47
            ],
48
            'spacing' => [
49
                'default' => [
50
                    'unit' => 'em',
51
                    'size' => 2,
52
                ],
53
                'is_responsive' => true,
54
                'label' => esc_html_x('Review Spacing', 'admin-text', 'site-reviews'),
55
                'range' => [
56
                    'em' => [
57
                        'min' => 0,
58
                        'max' => 4,
59
                        'step' => 0.125,
60
                    ],
61
                ],
62
                'selectors' => [
63
                    '{{WRAPPER}} .glsr-reviews' => '--glsr-gap-xl: {{SIZE}}{{UNIT}};',
64
                ],
65
                'size_units' => ['em', 'custom'],
66
                'type' => Controls_Manager::SLIDER,
67
            ],
68
            'rating_color' => [
69
                'global' => [
70
                    'default' => '',
71
                ],
72
                'label' => esc_html_x('Color', 'admin-text', 'site-reviews'),
73
                'selectors' => [
74
                    '{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star-empty' => 'background: {{VALUE}} !important;',
75
                    '{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star-full' => 'background: {{VALUE}} !important;',
76
                    '{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star-half' => 'background: {{VALUE}} !important;',
77
                ],
78
                'type' => Controls_Manager::COLOR,
79
            ],
80
            'rating_size' => [
81
                'default' => [
82
                    'unit' => 'em',
83
                    'size' => 1.25,
84
                ],
85
                'is_responsive' => true,
86
                'label' => esc_html_x('Star Size', 'admin-text', 'site-reviews'),
87
                'range' => [
88
                    'em' => [
89
                        'min' => 0.25,
90
                        'max' => 2.25,
91
                        'step' => 0.125,
92
                    ],
93
                ],
94
                'selectors' => [
95
                    '{{WRAPPER}} .glsr:not([data-theme]) .glsr-review .glsr-star' => '--glsr-review-star: {{SIZE}}{{UNIT}};',
96
                ],
97
                'size_units' => ['em', 'custom'],
98
                'type' => Controls_Manager::SLIDER,
99
            ],
100
        ];
101
    }
102
}
103