Conditions | 1 |
Paths | 1 |
Total Lines | 131 |
Code Lines | 91 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
42 | public function dataOptions(): array |
||
43 | { |
||
44 | return [ |
||
45 | [ |
||
46 | new Number(), |
||
47 | [ |
||
48 | 'min' => null, |
||
49 | 'max' => null, |
||
50 | 'incorrectInputMessage' => [ |
||
51 | 'template' => 'The allowed types are integer, float and string.', |
||
52 | 'parameters' => [], |
||
53 | ], |
||
54 | 'notNumberMessage' => [ |
||
55 | 'template' => 'Value must be a number.', |
||
56 | 'parameters' => [], |
||
57 | ], |
||
58 | 'lessThanMinMessage' => [ |
||
59 | 'template' => 'Value must be no less than {min}.', |
||
60 | 'parameters' => ['min' => null], |
||
61 | ], |
||
62 | 'greaterThanMaxMessage' => [ |
||
63 | 'template' => 'Value must be no greater than {max}.', |
||
64 | 'parameters' => ['max' => null], |
||
65 | ], |
||
66 | 'skipOnEmpty' => false, |
||
67 | 'skipOnError' => false, |
||
68 | 'pattern' => '/^\s*[-+]?\d*\.?\d+([eE][-+]?\d+)?\s*$/', |
||
69 | ], |
||
70 | ], |
||
71 | [ |
||
72 | new Number(min: 1), |
||
73 | [ |
||
74 | 'min' => 1, |
||
75 | 'max' => null, |
||
76 | 'incorrectInputMessage' => [ |
||
77 | 'template' => 'The allowed types are integer, float and string.', |
||
78 | 'parameters' => [], |
||
79 | ], |
||
80 | 'notNumberMessage' => [ |
||
81 | 'template' => 'Value must be a number.', |
||
82 | 'parameters' => [], |
||
83 | ], |
||
84 | 'lessThanMinMessage' => [ |
||
85 | 'template' => 'Value must be no less than {min}.', |
||
86 | 'parameters' => ['min' => 1], |
||
87 | ], |
||
88 | 'greaterThanMaxMessage' => [ |
||
89 | 'template' => 'Value must be no greater than {max}.', |
||
90 | 'parameters' => ['max' => null], |
||
91 | ], |
||
92 | 'skipOnEmpty' => false, |
||
93 | 'skipOnError' => false, |
||
94 | 'pattern' => '/^\s*[-+]?\d*\.?\d+([eE][-+]?\d+)?\s*$/', |
||
95 | ], |
||
96 | ], |
||
97 | [ |
||
98 | new Number(max: 1), |
||
99 | [ |
||
100 | 'min' => null, |
||
101 | 'max' => 1, |
||
102 | 'incorrectInputMessage' => [ |
||
103 | 'template' => 'The allowed types are integer, float and string.', |
||
104 | 'parameters' => [], |
||
105 | ], |
||
106 | 'notNumberMessage' => [ |
||
107 | 'template' => 'Value must be a number.', |
||
108 | 'parameters' => [], |
||
109 | ], |
||
110 | 'lessThanMinMessage' => [ |
||
111 | 'template' => 'Value must be no less than {min}.', |
||
112 | 'parameters' => ['min' => null], |
||
113 | ], |
||
114 | 'greaterThanMaxMessage' => [ |
||
115 | 'template' => 'Value must be no greater than {max}.', |
||
116 | 'parameters' => ['max' => 1], |
||
117 | ], |
||
118 | 'skipOnEmpty' => false, |
||
119 | 'skipOnError' => false, |
||
120 | 'pattern' => '/^\s*[-+]?\d*\.?\d+([eE][-+]?\d+)?\s*$/', |
||
121 | ], |
||
122 | ], |
||
123 | [ |
||
124 | new Number(min: 2, max: 10), |
||
125 | [ |
||
126 | 'min' => 2, |
||
127 | 'max' => 10, |
||
128 | 'incorrectInputMessage' => [ |
||
129 | 'template' => 'The allowed types are integer, float and string.', |
||
130 | 'parameters' => [], |
||
131 | ], |
||
132 | 'notNumberMessage' => [ |
||
133 | 'template' => 'Value must be a number.', |
||
134 | 'parameters' => [], |
||
135 | ], |
||
136 | 'lessThanMinMessage' => [ |
||
137 | 'template' => 'Value must be no less than {min}.', |
||
138 | 'parameters' => ['min' => 2], |
||
139 | ], |
||
140 | 'greaterThanMaxMessage' => [ |
||
141 | 'template' => 'Value must be no greater than {max}.', |
||
142 | 'parameters' => ['max' => 10], |
||
143 | ], |
||
144 | 'skipOnEmpty' => false, |
||
145 | 'skipOnError' => false, |
||
146 | 'pattern' => '/^\s*[-+]?\d*\.?\d+([eE][-+]?\d+)?\s*$/', |
||
147 | ], |
||
148 | ], |
||
149 | [ |
||
150 | new Integer(), |
||
151 | [ |
||
152 | 'min' => null, |
||
153 | 'max' => null, |
||
154 | 'incorrectInputMessage' => [ |
||
155 | 'template' => 'The allowed types are integer, float and string.', |
||
156 | 'parameters' => [], |
||
157 | ], |
||
158 | 'notNumberMessage' => [ |
||
159 | 'template' => 'Value must be an integer.', |
||
160 | 'parameters' => [], |
||
161 | ], |
||
162 | 'lessThanMinMessage' => [ |
||
163 | 'template' => 'Value must be no less than {min}.', |
||
164 | 'parameters' => ['min' => null], |
||
165 | ], |
||
166 | 'greaterThanMaxMessage' => [ |
||
167 | 'template' => 'Value must be no greater than {max}.', |
||
168 | 'parameters' => ['max' => null], |
||
169 | ], |
||
170 | 'skipOnEmpty' => false, |
||
171 | 'skipOnError' => false, |
||
172 | 'pattern' => '/^\s*[+-]?\d+\s*$/', |
||
173 | ], |
||
285 |