Test Failed
Push — develop ( 8b2a32...47c531 )
by Paul
08:13
created

FlatsomeSiteReviewsForm::options()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 83
Code Lines 68

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 68
c 1
b 0
f 1
dl 0
loc 83
rs 8.6981
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\Flatsome;
4
5
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract;
6
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsFormShortcode;
7
8
class FlatsomeSiteReviewsForm extends FlatsomeShortcode
9
{
10
    public function options(): array
11
    {
12
        return [
13
            'assignment_group' => [
14
                'type' => 'group',
15
                'heading' => esc_html_x('Review Assignment', 'admin-text', 'site-reviews'),
16
                'options' => [
17
                    'assigned_posts' => [
18
                        'type' => 'select',
19
                        'heading' => esc_html_x('Assign New Reviews to Pages', 'admin-text', 'site-reviews'),
20
                        'default' => '',
21
                        'full_width' => true,
22
                        'config' => [
23
                            'multiple' => true,
24
                            'placeholder' => esc_html_x('Select...', 'admin-text', 'site-reviews'),
25
                            'postSelect' => 'assigned_posts_query',
26
                        ],
27
                    ],
28
                    'assigned_terms' => [
29
                        'type' => 'select',
30
                        'heading' => esc_html_x('Assign New Reviews to Categories', 'admin-text', 'site-reviews'),
31
                        'default' => '',
32
                        'full_width' => true,
33
                        'config' => [
34
                            'multiple' => true,
35
                            'placeholder' => esc_html_x('Select...', 'admin-text', 'site-reviews'),
36
                            'termSelect' => [
37
                                'taxonomies' => glsr()->taxonomy,
38
                            ],
39
                        ],
40
                    ],
41
                    'assigned_users' => [
42
                        'type' => 'select',
43
                        'heading' => esc_html_x('Assign New Reviews to Users', 'admin-text', 'site-reviews'),
44
                        'default' => '',
45
                        'full_width' => true,
46
                        'config' => [
47
                            'multiple' => true,
48
                            'placeholder' => esc_html_x('Select...', 'admin-text', 'site-reviews'),
49
                            'postSelect' => 'assigned_users_query',
50
                        ],
51
                    ],
52
                ],
53
            ],
54
            'hide_group' => [
55
                'type' => 'group',
56
                'heading' => esc_html_x('Hide Fields', 'admin-text', 'site-reviews'),
57
                'options' => $this->hideOptions(),
58
            ],
59
            'advanced_group' => [
60
                'type' => 'group',
61
                'heading' => esc_html_x('Advanced', 'admin-text', 'site-reviews'),
62
                'options' => [
63
                    'id' => [
64
                        'type' => 'textfield',
65
                        'heading' => esc_html_x('Custom ID', 'admin-text', 'site-reviews'),
66
                        'description' => esc_html_x('This should be a unique value.', 'admin-text', 'site-reviews'),
67
                        'full_width' => true,
68
                    ],
69
                    'reviews_id' => [
70
                        'type' => 'textfield',
71
                        'heading' => esc_html_x('Custom Reviews ID', 'admin-text', 'site-reviews'),
72
                        'description' => esc_html_x('Enter the Custom ID of a reviews block, shortcode, or widget where the review should be displayed after submission.', 'admin-text', 'site-reviews'),
73
                        'full_width' => true,
74
                    ],
75
                    'class' => [
76
                        'type' => 'textfield',
77
                        'heading' => esc_html_x('Additional CSS classes', 'admin-text', 'site-reviews'),
78
                        'description' => esc_html_x('Separate multiple classes with spaces.', 'admin-text', 'site-reviews'),
79
                        'full_width' => true,
80
                    ],
81
                    'visibility' => [
82
                        'type' => 'select',
83
                        'heading' => esc_html_x('Visibility', 'admin-text', 'site-reviews'),
84
                        'default' => '',
85
                        'options' => [
86
                            '' => esc_html_x('Visible', 'admin-text', 'site-reviews'),
87
                            'hidden' => esc_html_x('Hidden', 'admin-text', 'site-reviews'),
88
                            'hide-for-medium' => esc_html_x('Only for Desktop', 'admin-text', 'site-reviews'),
89
                            'show-for-small' => esc_html_x('Only for Mobile', 'admin-text', 'site-reviews'),
90
                            'show-for-medium hide-for-small' => esc_html_x('Only for Tablet', 'admin-text', 'site-reviews'),
91
                            'show-for-medium' => esc_html_x('Hide for Desktop', 'admin-text', 'site-reviews'),
92
                            'hide-for-small' => esc_html_x('Hide for Mobile', 'admin-text', 'site-reviews'),
93
                        ],
94
                    ],
95
                ],
96
            ],
97
        ];
98
    }
99
100
    protected function icon(): string
101
    {
102
        return glsr()->url('assets/images/icons/flatsome/flatsome-form.svg');
103
    }
104
105
    protected function name(): string
106
    {
107
        return esc_attr_x('Review Form', 'admin-text', 'site-reviews');
108
    }
109
110
    protected function shortcode(): ShortcodeContract
111
    {
112
        return glsr(SiteReviewsFormShortcode::class);
1 ignored issue
show
Bug Best Practice introduced by
The expression return glsr(GeminiLabs\S...wsFormShortcode::class) could return the type callable which is incompatible with the type-hinted return GeminiLabs\SiteReviews\Contracts\ShortcodeContract. Consider adding an additional type-check to rule them out.
Loading history...
113
    }
114
}
115