Conditions | 1 |
Paths | 1 |
Total Lines | 254 |
Code Lines | 249 |
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 |
||
67 | public function getTests(): array |
||
68 | { |
||
69 | $resource = self::getResource(); |
||
70 | |||
71 | return [ |
||
72 | ['string', ['value'], true], |
||
73 | ['string', [''], true], |
||
74 | ['string', [1234], false], |
||
75 | ['stringNotEmpty', ['value'], true], |
||
76 | ['stringNotEmpty', [''], false], |
||
77 | ['stringNotEmpty', [1234], false], |
||
78 | ['integer', [123], true], |
||
79 | ['integer', ['123'], false], |
||
80 | ['integer', [1.0], false], |
||
81 | ['integer', [1.23], false], |
||
82 | ['integerish', [1.0], true], |
||
83 | ['integerish', [1.23], false], |
||
84 | ['integerish', [123], true], |
||
85 | ['integerish', ['123'], true], |
||
86 | ['float', [1.0], true], |
||
87 | ['float', [1.23], true], |
||
88 | ['float', [123], false], |
||
89 | ['float', ['123'], false], |
||
90 | ['numeric', [1.0], true], |
||
91 | ['numeric', [1.23], true], |
||
92 | ['numeric', [123], true], |
||
93 | ['numeric', ['123'], true], |
||
94 | ['numeric', ['foo'], false], |
||
95 | ['boolean', [true], true], |
||
96 | ['boolean', [false], true], |
||
97 | ['boolean', [1], false], |
||
98 | ['boolean', ['1'], false], |
||
99 | ['scalar', ['1'], true], |
||
100 | ['scalar', [123], true], |
||
101 | ['scalar', [true], true], |
||
102 | ['scalar', [null], false], |
||
103 | ['scalar', [[]], false], |
||
104 | ['scalar', [new stdClass()], false], |
||
105 | ['object', [new stdClass()], true], |
||
106 | ['object', [new RuntimeException()], true], |
||
107 | ['object', [null], false], |
||
108 | ['object', [true], false], |
||
109 | ['object', [1], false], |
||
110 | ['object', [[]], false], |
||
111 | ['resource', [$resource], true], |
||
112 | ['resource', [$resource, 'stream'], true], |
||
113 | ['resource', [$resource, 'other'], false], |
||
114 | ['resource', [1], false], |
||
115 | ['isCallable', ['strlen'], true], |
||
116 | ['isCallable', [[$this, 'getTests']], true], |
||
117 | ['isCallable', [static function () { }], true], |
||
118 | ['isCallable', [1234], false], |
||
119 | ['isCallable', ['foobar'], false], |
||
120 | ['isArray', [[]], true], |
||
121 | ['isArray', [[1, 2, 3]], true], |
||
122 | ['isArray', [new ArrayIterator([])], false], |
||
123 | ['isArray', [123], false], |
||
124 | ['isArray', [new stdClass()], false], |
||
125 | ['isTraversable', [[]], true], |
||
126 | ['isTraversable', [[1, 2, 3]], true], |
||
127 | ['isTraversable', [new ArrayIterator([])], true], |
||
128 | ['isTraversable', [123], false], |
||
129 | ['isTraversable', [new stdClass()], false], |
||
130 | ['isInstanceOf', [new stdClass(), 'stdClass'], true], |
||
131 | ['isInstanceOf', [new Exception(), 'stdClass'], false], |
||
132 | ['isInstanceOf', [123, 'stdClass'], false], |
||
133 | ['isInstanceOf', [[], 'stdClass'], false], |
||
134 | ['notInstanceOf', [new stdClass(), 'stdClass'], false], |
||
135 | ['notInstanceOf', [new Exception(), 'stdClass'], true], |
||
136 | ['notInstanceOf', [123, 'stdClass'], true], |
||
137 | ['notInstanceOf', [[], 'stdClass'], true], |
||
138 | ['true', [true], true], |
||
139 | ['true', [false], false], |
||
140 | ['true', [1], false], |
||
141 | ['true', [null], false], |
||
142 | ['false', [false], true], |
||
143 | ['false', [true], false], |
||
144 | ['false', [1], false], |
||
145 | ['false', [0], false], |
||
146 | ['false', [null], false], |
||
147 | ['null', [null], true], |
||
148 | ['null', [false], false], |
||
149 | ['null', [0], false], |
||
150 | ['notNull', [false], true], |
||
151 | ['notNull', [0], true], |
||
152 | ['notNull', [null], false], |
||
153 | ['isEmpty', [null], true], |
||
154 | ['isEmpty', [false], true], |
||
155 | ['isEmpty', [0], true], |
||
156 | ['isEmpty', [''], true], |
||
157 | ['isEmpty', [1], false], |
||
158 | ['isEmpty', ['a'], false], |
||
159 | ['notEmpty', [1], true], |
||
160 | ['notEmpty', ['a'], true], |
||
161 | ['notEmpty', [null], false], |
||
162 | ['notEmpty', [false], false], |
||
163 | ['notEmpty', [0], false], |
||
164 | ['notEmpty', [''], false], |
||
165 | ['eq', [1, 1], true], |
||
166 | ['eq', [1, '1'], true], |
||
167 | ['eq', [1, true], true], |
||
168 | ['eq', [1, 0], false], |
||
169 | ['notEq', [1, 0], true], |
||
170 | ['notEq', [1, 1], false], |
||
171 | ['notEq', [1, '1'], false], |
||
172 | ['notEq', [1, true], false], |
||
173 | ['same', [1, 1], true], |
||
174 | ['same', [1, '1'], false], |
||
175 | ['same', [1, true], false], |
||
176 | ['same', [1, 0], false], |
||
177 | ['notSame', [1, 0], true], |
||
178 | ['notSame', [1, 1], false], |
||
179 | ['notSame', [1, '1'], true], |
||
180 | ['notSame', [1, true], true], |
||
181 | ['greaterThan', [1, 0], true], |
||
182 | ['greaterThan', [0, 0], false], |
||
183 | ['greaterThanEq', [2, 1], true], |
||
184 | ['greaterThanEq', [1, 1], true], |
||
185 | ['greaterThanEq', [0, 1], false], |
||
186 | ['lessThan', [0, 1], true], |
||
187 | ['lessThan', [1, 1], false], |
||
188 | ['lessThanEq', [0, 1], true], |
||
189 | ['lessThanEq', [1, 1], true], |
||
190 | ['lessThanEq', [2, 1], false], |
||
191 | ['range', [1, 1, 2], true], |
||
192 | ['range', [2, 1, 2], true], |
||
193 | ['range', [0, 1, 2], false], |
||
194 | ['range', [3, 1, 2], false], |
||
195 | ['oneOf', [1, [1, 2, 3]], true], |
||
196 | ['oneOf', [1, ['1', '2', '3']], false], |
||
197 | ['contains', ['abcd', 'ab'], true], |
||
198 | ['contains', ['abcd', 'bc'], true], |
||
199 | ['contains', ['abcd', 'cd'], true], |
||
200 | ['contains', ['abcd', 'de'], false], |
||
201 | ['contains', ['', 'de'], false], |
||
202 | ['startsWith', ['abcd', 'ab'], true], |
||
203 | ['startsWith', ['abcd', 'bc'], false], |
||
204 | ['startsWith', ['', 'bc'], false], |
||
205 | ['startsWithLetter', ['abcd'], true], |
||
206 | ['startsWithLetter', ['1abcd'], false], |
||
207 | ['startsWithLetter', [''], false], |
||
208 | ['endsWith', ['abcd', 'cd'], true], |
||
209 | ['endsWith', ['abcd', 'bc'], false], |
||
210 | ['endsWith', ['', 'bc'], false], |
||
211 | ['regex', ['abcd', '~^ab~'], true], |
||
212 | ['regex', ['abcd', '~^bc~'], false], |
||
213 | ['regex', ['', '~^bc~'], false], |
||
214 | ['alpha', ['abcd'], true], |
||
215 | ['alpha', ['ab1cd'], false], |
||
216 | ['alpha', [''], false], |
||
217 | ['digits', ['1234'], true], |
||
218 | ['digits', ['12a34'], false], |
||
219 | ['digits', [''], false], |
||
220 | ['alnum', ['ab12'], true], |
||
221 | ['alnum', ['ab12$'], false], |
||
222 | ['alnum', [''], false], |
||
223 | ['lower', ['abcd'], true], |
||
224 | ['lower', ['abCd'], false], |
||
225 | ['lower', ['ab_d'], false], |
||
226 | ['lower', [''], false], |
||
227 | ['upper', ['ABCD'], true], |
||
228 | ['upper', ['ABcD'], false], |
||
229 | ['upper', ['AB_D'], false], |
||
230 | ['upper', [''], false], |
||
231 | ['length', ['abcd', 4], true], |
||
232 | ['length', ['abc', 4], false], |
||
233 | ['length', ['abcde', 4], false], |
||
234 | ['length', ['äbcd', 4], true, true], |
||
235 | ['length', ['äbc', 4], false, true], |
||
236 | ['length', ['äbcde', 4], false, true], |
||
237 | ['minLength', ['abcd', 4], true], |
||
238 | ['minLength', ['abcde', 4], true], |
||
239 | ['minLength', ['abc', 4], false], |
||
240 | ['minLength', ['äbcd', 4], true, true], |
||
241 | ['minLength', ['äbcde', 4], true, true], |
||
242 | ['minLength', ['äbc', 4], false, true], |
||
243 | ['maxLength', ['abcd', 4], true], |
||
244 | ['maxLength', ['abc', 4], true], |
||
245 | ['maxLength', ['abcde', 4], false], |
||
246 | ['maxLength', ['äbcd', 4], true, true], |
||
247 | ['maxLength', ['äbc', 4], true, true], |
||
248 | ['maxLength', ['äbcde', 4], false, true], |
||
249 | ['lengthBetween', ['abcd', 3, 5], true], |
||
250 | ['lengthBetween', ['abc', 3, 5], true], |
||
251 | ['lengthBetween', ['abcde', 3, 5], true], |
||
252 | ['lengthBetween', ['ab', 3, 5], false], |
||
253 | ['lengthBetween', ['abcdef', 3, 5], false], |
||
254 | ['lengthBetween', ['äbcd', 3, 5], true, true], |
||
255 | ['lengthBetween', ['äbc', 3, 5], true, true], |
||
256 | ['lengthBetween', ['äbcde', 3, 5], true, true], |
||
257 | ['lengthBetween', ['äb', 3, 5], false, true], |
||
258 | ['lengthBetween', ['äbcdef', 3, 5], false, true], |
||
259 | ['fileExists', [__FILE__], true], |
||
260 | ['fileExists', [__DIR__], true], |
||
261 | ['fileExists', [__DIR__ . '/foobar'], false], |
||
262 | ['file', [__FILE__], true], |
||
263 | ['file', [__DIR__], false], |
||
264 | ['file', [__DIR__ . '/foobar'], false], |
||
265 | ['directory', [__DIR__], true], |
||
266 | ['directory', [__FILE__], false], |
||
267 | ['directory', [__DIR__ . '/foobar'], false], |
||
268 | // no tests for readable()/writable() for now |
||
269 | ['classExists', [__CLASS__], true], |
||
270 | ['classExists', [__NAMESPACE__ . '\Foobar'], false], |
||
271 | ['subclassOf', [__CLASS__, TestCase::class], true], |
||
272 | ['subclassOf', [__CLASS__, 'stdClass'], false], |
||
273 | ['implementsInterface', ['ArrayIterator', 'Traversable'], true], |
||
274 | ['implementsInterface', [__CLASS__, 'Traversable'], false], |
||
275 | ['propertyExists', [(object)['property' => 0], 'property'], true], |
||
276 | ['propertyExists', [(object)['property' => null], 'property'], true], |
||
277 | ['propertyExists', [(object)['property' => null], 'foo'], false], |
||
278 | ['propertyNotExists', [(object)['property' => 0], 'property'], false], |
||
279 | ['propertyNotExists', [(object)['property' => null], 'property'], false], |
||
280 | ['propertyNotExists', [(object)['property' => null], 'foo'], true], |
||
281 | ['methodExists', ['RuntimeException', 'getMessage'], true], |
||
282 | ['methodExists', [new RuntimeException(), 'getMessage'], true], |
||
283 | ['methodExists', ['stdClass', 'getMessage'], false], |
||
284 | ['methodExists', [new stdClass(), 'getMessage'], false], |
||
285 | ['methodExists', [null, 'getMessage'], false], |
||
286 | ['methodExists', [true, 'getMessage'], false], |
||
287 | ['methodExists', [1, 'getMessage'], false], |
||
288 | ['methodNotExists', ['RuntimeException', 'getMessage'], false], |
||
289 | ['methodNotExists', [new RuntimeException(), 'getMessage'], false], |
||
290 | ['methodNotExists', ['stdClass', 'getMessage'], true], |
||
291 | ['methodNotExists', [new stdClass(), 'getMessage'], true], |
||
292 | ['methodNotExists', [null, 'getMessage'], true], |
||
293 | ['methodNotExists', [true, 'getMessage'], true], |
||
294 | ['methodNotExists', [1, 'getMessage'], true], |
||
295 | ['keyExists', [['key' => 0], 'key'], true], |
||
296 | ['keyExists', [['key' => null], 'key'], true], |
||
297 | ['keyExists', [['key' => null], 'foo'], false], |
||
298 | ['keyNotExists', [['key' => 0], 'key'], false], |
||
299 | ['keyNotExists', [['key' => null], 'key'], false], |
||
300 | ['keyNotExists', [['key' => null], 'foo'], true], |
||
301 | ['count', [[0, 1, 2], 3], true], |
||
302 | ['count', [[0, 1, 2], 2], false], |
||
303 | ['uuid', ['00000000-0000-0000-0000-000000000000'], true], |
||
304 | ['uuid', ['ff6f8cb0-c57d-21e1-9b21-0800200c9a66'], true], |
||
305 | ['uuid', ['ff6f8cb0-c57d-11e1-9b21-0800200c9a66'], true], |
||
306 | ['uuid', ['ff6f8cb0-c57d-31e1-9b21-0800200c9a66'], true], |
||
307 | ['uuid', ['ff6f8cb0-c57d-41e1-9b21-0800200c9a66'], true], |
||
308 | ['uuid', ['ff6f8cb0-c57d-51e1-9b21-0800200c9a66'], true], |
||
309 | ['uuid', ['FF6F8CB0-C57D-11E1-9B21-0800200C9A66'], true], |
||
310 | ['uuid', ['zf6f8cb0-c57d-11e1-9b21-0800200c9a66'], false], |
||
311 | ['uuid', ['af6f8cb0c57d11e19b210800200c9a66'], false], |
||
312 | ['uuid', ['ff6f8cb0-c57da-51e1-9b21-0800200c9a66'], false], |
||
313 | ['uuid', ['af6f8cb-c57d-11e1-9b21-0800200c9a66'], false], |
||
314 | ['uuid', ['3f6f8cb0-c57d-11e1-9b21-0800200c9a6'], false], |
||
315 | ['throws', [function () { throw new LogicException('test'); }, 'LogicException'], true], |
||
316 | ['throws', [function () { throw new LogicException('test'); }, 'IllogicException'], false], |
||
317 | ['throws', [function () { throw new Exception('test'); }], true], |
||
318 | //array('throws', array(function() { trigger_error('test'); }, 'Throwable'), true, false, 70000), |
||
319 | ['throws', [function () { trigger_error('test'); }, 'Unthrowable'], false, false, 70000], |
||
320 | ['throws', [function () { throw new Error(); }, 'Throwable'], true, true, 70000], |
||
321 | ]; |
||
478 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths