Test Failed
Push — develop ( db5b9c...b55dd4 )
by Paul
17:52
created

SiteReviewsWidget::widgetConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 60
Code Lines 48

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 48
c 0
b 0
f 0
dl 0
loc 60
ccs 0
cts 57
cp 0
rs 9.1344
cc 1
nc 1
nop 0
crap 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A SiteReviewsWidget::wShortcode() 0 3 1

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\Widgets;
4
5
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract;
6
use GeminiLabs\SiteReviews\Modules\Rating;
7
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsShortcode;
8
9
class SiteReviewsWidget extends Widget
10
{
11
    protected function wConfig(): array
12
    {
13
        return [
14
            'assigned_posts' => [
15
                'description' => esc_html_x('Enter "post_id" to use the Post ID of the current page.', 'admin-text', 'site-reviews'),
16
                'label' => esc_html_x('Limit Reviews by Assigned Pages', 'admin-text', 'site-reviews'),
17
                'type' => 'text',
18
            ],
19
            'assigned_users' => [
20
                'description' => esc_html_x('Enter "user_id" to use the ID of the logged-in user.', 'admin-text', 'site-reviews'),
21
                'label' => esc_html_x('Limit Reviews by Assigned Users', 'admin-text', 'site-reviews'),
22
                'type' => 'text',
23
            ],
24
            'assigned_terms' => [
25
                'label' => esc_html_x('Limit Reviews by Categories', 'admin-text', 'site-reviews'),
26
                'options' => $this->fieldAssignedTermsOptions(),
27
                'type' => 'select',
28
            ],
29
            'terms' => [
30
                'label' => esc_html_x('Limit Reviews by Accepted Terms', 'admin-text', 'site-reviews'),
31
                'options' => $this->shortcode->options('terms', [
32
                    'placeholder' => _x('— Select —', 'admin-text', 'site-reviews'),
33
                ]),
34
                'type' => 'select',
35
            ],
36
            'type' => [
37
                'label' => esc_html_x('Limit Reviews by Type', 'admin-text', 'site-reviews'),
38
                'options' => $this->shortcode->options('type'),
39
                'type' => 'select',
40
                'value' => 'local',
41
            ],
42
            'display' => [
43
                'label' => esc_html_x('The number of reviews to show', 'admin-text', 'site-reviews'),
44
                'max' => 50,
45
                'min' => 1,
46
                'type' => 'number',
47
                'value' => 10,
48
            ],
49
            'rating' => [
50
                'label' => esc_html_x('The minimum rating to display', 'admin-text', 'site-reviews'),
51
                'max' => Rating::max(),
52
                'min' => Rating::min(),
53
                'type' => 'number',
54
                'value' => Rating::min(),
55
            ],
56
            'hide' => [
57
                'options' => $this->shortcode->options('hide'),
58
                'type' => 'checkbox',
59
            ],
60
            'id' => [
61
                'description' => esc_html_x('This should be a unique value.', 'admin-text', 'site-reviews'),
62
                'label' => esc_html_x('Custom ID', 'admin-text', 'site-reviews'),
63
                'type' => 'text',
64
            ],
65
            'class' => [
66
                'description' => esc_html_x('Separate multiple classes with spaces.', 'admin-text', 'site-reviews'),
67
                'label' => esc_html_x('Additional CSS classes', 'admin-text', 'site-reviews'),
68
                'type' => 'text',
69
            ],
70
        ];
71
    }
72
73
    protected function wShortcode(): ShortcodeContract
74
    {
75
        return glsr(SiteReviewsShortcode::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return glsr(GeminiLabs\S...eviewsShortcode::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...
76
    }
77
}
78