Test Failed
Push — develop ( 37d80d...39822a )
by Paul
08:38
created

SiteReviewsSummaryTinymce::fields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 79
Code Lines 54

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 51
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 54
c 0
b 0
f 0
dl 0
loc 79
ccs 51
cts 51
cp 1
rs 9.0036
cc 1
nc 1
nop 0
crap 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\Tinymce;
4
5
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract;
6
use GeminiLabs\SiteReviews\Modules\Rating;
7 8
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsSummaryShortcode;
8
9 8
class SiteReviewsSummaryTinymce extends TinymceGenerator
10 8
{
11 8
    public function fields(): array
12 8
    {
13 8
        return [
14 8
            [
15 8
                'label' => esc_html_x('Assigned Pages', 'admin-text', 'site-reviews'),
16 8
                'name' => 'assigned_posts',
17 8
                'tooltip' => sprintf(esc_html_x('Limit reviews to those assigned to a Post ID. You may also enter %s to use the Post ID of the current page.', 'admin-text', 'site-reviews'), '"post_id"'),
18 8
                'type' => 'textbox',
19 8
            ],
20 8
            [
21 8
                'label' => esc_html_x('Assigned Categories', 'admin-text', 'site-reviews'),
22 8
                'name' => 'assigned_terms',
23 8
                'tooltip' => esc_html_x('Limit reviews to those assigned to a category. You may enter a Term ID or slug.', 'admin-text', 'site-reviews'),
24 8
                'type' => 'textbox',
25 8
            ],
26 8
            [
27 8
                'label' => esc_html_x('Assigned Users', 'admin-text', 'site-reviews'),
28 8
                'name' => 'assigned_users',
29 8
                'tooltip' => sprintf(esc_html_x('Limit reviews to those assigned to a User ID. You may also enter %s to use the ID of the logged-in user.', 'admin-text', 'site-reviews'), '"user_id"'),
30 8
                'type' => 'textbox',
31 8
            ],
32 8
            [
33 8
                'label' => esc_html_x('Terms Accepted', 'admin-text', 'site-reviews'),
34 8
                'name' => 'terms',
35 8
                'options' => $this->shortcode->options('terms'),
36 8
                'tooltip' => esc_html_x('Limit Reviews by terms accepted', 'admin-text', 'site-reviews'),
37 8
                'type' => 'listbox',
38 8
            ],
39 8
            [
40 8
                'label' => esc_html_x('Review Type', 'admin-text', 'site-reviews'),
41 8
                'name' => 'type',
42 8
                'options' => $this->shortcode->options('type'),
43 8
                'tooltip' => esc_html_x('Limit Reviews by review type', 'admin-text', 'site-reviews'),
44 8
                'type' => 'listbox',
45 8
            ],
46 8
            [
47 8
                'label' => esc_html_x('Minimum Rating', 'admin-text', 'site-reviews'),
48 8
                'name' => 'rating',
49 8
                'options' => glsr(Rating::class)->optionsArray(),
50 8
                'tooltip' => esc_html_x('The minimum rating to display (default: 1 star)?', 'admin-text', 'site-reviews'),
51 8
                'type' => 'listbox',
52 8
            ],
53 8
            [
54 8
                'label' => esc_html_x('Rating Field Name', 'admin-text', 'site-reviews'),
55 8
                'name' => 'rating_field',
56 8
                'tooltip' => sprintf(esc_html_x('Use the %s addon to add custom rating fields.', 'admin-text', 'site-reviews'),
57 8
                    sprintf('"%s"', _x('Review Forms', 'addon name (admin-text)', 'site-reviews'))
58 8
                ),
59 8
                'type' => 'textbox',
60
            ],
61
            [
62 8
                'label' => esc_html_x('Schema', 'admin-text', 'site-reviews'),
63
                'name' => 'schema',
64 8
                'options' => [
65
                    '' => esc_html_x('Disabled', 'admin-text', 'site-reviews'),
66
                    'true' => esc_html_x('Enabled', 'admin-text', 'site-reviews'),
67
                ],
68
                'tooltip' => esc_html_x('Rich snippets are disabled by default.', 'admin-text', 'site-reviews'),
69
                'type' => 'listbox',
70
            ],
71
            [
72
                'columns' => 2,
73
                'items' => $this->hideOptions(),
74
                'label' => esc_html_x('Hide', 'admin-text', 'site-reviews'),
75
                'layout' => 'grid',
76
                'spacing' => 5,
77
                'type' => 'container',
78
            ],
79
            [
80
                'label' => esc_html_x('Custom ID', 'admin-text', 'site-reviews'),
81
                'name' => 'id',
82
                'tooltip' => esc_html_x('This should be a unique value.', 'admin-text', 'site-reviews'),
83
                'type' => 'textbox',
84
            ],
85
            [
86
                'label' => esc_html_x('Additional CSS classes', 'admin-text', 'site-reviews'),
87
                'name' => 'class',
88
                'tooltip' => esc_html_x('Separate multiple classes with spaces.', 'admin-text', 'site-reviews'),
89
                'type' => 'textbox',
90
            ],
91
        ];
92
    }
93
94
    public function shortcode(): ShortcodeContract
95
    {
96
        return glsr(SiteReviewsSummaryShortcode::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return glsr(GeminiLabs\S...ummaryShortcode::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...
97
    }
98
}
99