Conditions | 1 |
Paths | 1 |
Total Lines | 110 |
Code Lines | 89 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
11 | public static function elementParameters(): array |
||
12 | { |
||
13 | return [ |
||
14 | 'assigned_posts' => [ |
||
15 | 'default' => '', |
||
16 | 'heading' => esc_attr_x('Limit Reviews to an Assigned Page', 'admin-text', 'site-reviews'), |
||
17 | 'param_name' => 'assigned_posts', |
||
18 | 'type' => 'multiple_select', |
||
19 | 'placeholder_text' => esc_attr_x('Select or Leave Blank', 'admin-text', 'site-reviews'), |
||
20 | 'value' => [ |
||
21 | 'custom' => esc_attr_x('Specific Post ID', 'admin-text', 'site-reviews'), |
||
22 | 'post_id' => esc_attr_x('The Current Page', 'admin-text', 'site-reviews'), |
||
23 | 'parent_id' => esc_attr_x('The Parent Page', 'admin-text', 'site-reviews'), |
||
24 | ], |
||
25 | ], |
||
26 | 'assigned_posts_custom' => [ |
||
27 | 'heading' => esc_attr_x('Assigned Post IDs', 'admin-text', 'site-reviews'), |
||
28 | 'description' => esc_attr_x('Separate values with a comma.', 'admin-text', 'site-reviews'), |
||
29 | 'param_name' => 'assigned_posts_custom', |
||
30 | 'type' => 'textfield', |
||
31 | 'value' => '', |
||
32 | 'dependency' => [ |
||
33 | [ |
||
34 | 'element' => 'assigned_posts', |
||
35 | 'value' => 'custom', |
||
36 | 'operator' => 'contains', |
||
37 | ], |
||
38 | ], |
||
39 | ], |
||
40 | 'assigned_terms' => static::optionAssignedTerms(esc_attr_x('Limit Reviews to an Assigned Category', 'admin-text', 'site-reviews')), |
||
41 | 'assigned_users' => [ |
||
42 | 'default' => '', |
||
43 | 'heading' => esc_attr_x('Limit Reviews to an Assigned User', 'admin-text', 'site-reviews'), |
||
44 | 'param_name' => 'assigned_users', |
||
45 | 'placeholder_text' => esc_attr_x('Select or Leave Blank', 'admin-text', 'site-reviews'), |
||
46 | 'type' => 'multiple_select', |
||
47 | 'value' => [ |
||
48 | 'custom' => esc_attr_x('Specific User ID', 'admin-text', 'site-reviews'), |
||
49 | 'user_id' => esc_attr_x('The Logged-in user', 'admin-text', 'site-reviews'), |
||
50 | 'author_id' => esc_attr_x('The Page author', 'admin-text', 'site-reviews'), |
||
51 | 'profile_id' => esc_attr_x('The Profile user (BuddyPress/Ultimate Member)', 'admin-text', 'site-reviews'), |
||
52 | ], |
||
53 | ], |
||
54 | 'assigned_users_custom' => [ |
||
55 | 'heading' => esc_attr_x('Assigned User IDs', 'admin-text', 'site-reviews'), |
||
56 | 'description' => esc_attr_x('Separate values with a comma.', 'admin-text', 'site-reviews'), |
||
57 | 'param_name' => 'assigned_users_custom', |
||
58 | 'type' => 'textfield', |
||
59 | 'value' => '', |
||
60 | 'dependency' => [ |
||
61 | [ |
||
62 | 'element' => 'assigned_users', |
||
63 | 'value' => 'custom', |
||
64 | 'operator' => 'contains', |
||
65 | ], |
||
66 | ], |
||
67 | ], |
||
68 | 'terms' => [ |
||
69 | 'default' => '', |
||
70 | 'heading' => esc_attr_x('Limit Reviews to Terms?', 'admin-text', 'site-reviews'), |
||
71 | 'param_name' => 'terms', |
||
72 | 'type' => 'select', |
||
73 | 'value' => [ |
||
74 | '' => esc_attr_x('No', 'admin-text', 'site-reviews'), |
||
75 | 'true' => esc_attr_x('Terms were accepted', 'admin-text', 'site-reviews'), |
||
76 | 'false' => esc_attr_x('Terms were not accepted', 'admin-text', 'site-reviews'), |
||
77 | ], |
||
78 | ], |
||
79 | 'type' => static::optionReviewTypes(), |
||
80 | 'rating' => [ |
||
81 | 'default' => 0, |
||
82 | 'heading' => esc_html_x('Minimum Rating', 'admin-text', 'site-reviews'), |
||
83 | 'max' => Cast::toInt(glsr()->constant('MAX_RATING', Rating::class)), |
||
84 | 'min' => Cast::toInt(glsr()->constant('MIN_RATING', Rating::class)), |
||
85 | 'param_name' => 'rating', |
||
86 | 'type' => 'range', |
||
87 | 'value' => 0, |
||
88 | ], |
||
89 | 'schema' => [ |
||
90 | 'default' => 0, |
||
91 | 'description' => _x('The schema should only be enabled once per page.', 'admin-text', 'site-reviews'), |
||
92 | 'heading' => esc_html_x('Enable the schema?', 'admin-text', 'site-reviews'), |
||
93 | 'param_name' => 'schema', |
||
94 | 'type' => 'radio_button_set', |
||
95 | 'value' => [ |
||
96 | 0 => esc_html_x('No', 'admin-text', 'site-reviews'), |
||
97 | 1 => esc_html_x('Yes', 'admin-text', 'site-reviews'), |
||
98 | ], |
||
99 | ], |
||
100 | 'hide' => [ |
||
101 | 'default' => '', |
||
102 | 'heading' => esc_html_x('Hide Fields', 'admin-text', 'site-reviews'), |
||
103 | 'param_name' => 'hide', |
||
104 | 'placeholder_text' => esc_attr_x('Select Fields to Hide', 'admin-text', 'site-reviews'), |
||
105 | 'type' => 'multiple_select', |
||
106 | 'value' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(), |
||
107 | ], |
||
108 | 'class' => [ |
||
109 | 'heading' => esc_attr_x('CSS Class', 'admin-text', 'site-reviews'), |
||
110 | 'description' => esc_attr_x('Add a class to the wrapping HTML element.', 'admin-text', 'site-reviews'), |
||
111 | 'param_name' => 'class', |
||
112 | 'type' => 'textfield', |
||
113 | 'value' => '', |
||
114 | ], |
||
115 | 'id' => [ |
||
116 | 'heading' => esc_attr_x('CSS ID', 'admin-text', 'site-reviews'), |
||
117 | 'description' => esc_attr_x('Add an ID to the wrapping HTML element.', 'admin-text', 'site-reviews'), |
||
118 | 'param_name' => 'id', |
||
119 | 'type' => 'textfield', |
||
120 | 'value' => '', |
||
121 | ], |
||
143 |