Conditions | 1 |
Paths | 1 |
Total Lines | 191 |
Code Lines | 116 |
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 |
||
200 | public function formDataProvider() |
||
201 | { |
||
202 | return [ |
||
203 | 'completely-valid-input' => [ |
||
204 | [ |
||
205 | 'user' => 2, |
||
206 | 'date' => '12-04-1988', |
||
207 | 'startTime' => '08:00', |
||
208 | 'endTime' => '17:00', |
||
209 | 'notes' => 'Some notes', |
||
210 | ], |
||
211 | [ |
||
212 | 'user' => 2, |
||
213 | 'date' => new \DateTime('12-04-1988'), |
||
214 | 'startTime' => '08:00', |
||
215 | 'endTime' => '17:00', |
||
216 | 'notes' => 'Some notes', |
||
217 | ], |
||
218 | null, |
||
219 | ], |
||
220 | 'valid-time-low-boundary' => [ |
||
221 | [ |
||
222 | 'user' => 2, |
||
223 | 'date' => '12-04-1988', |
||
224 | 'startTime' => '07:00', |
||
225 | 'endTime' => '16:00', |
||
226 | 'notes' => 'Some notes', |
||
227 | ], |
||
228 | [ |
||
229 | 'user' => 2, |
||
230 | 'date' => new \DateTime('12-04-1988'), |
||
231 | 'startTime' => '07:00', |
||
232 | 'endTime' => '16:00', |
||
233 | 'notes' => 'Some notes', |
||
234 | ], |
||
235 | null, |
||
236 | ], |
||
237 | 'valid-time-high-boundary' => [ |
||
238 | [ |
||
239 | 'user' => 2, |
||
240 | 'date' => '12-04-1988', |
||
241 | 'startTime' => '10:00', |
||
242 | 'endTime' => '19:00', |
||
243 | 'notes' => 'Some notes', |
||
244 | ], |
||
245 | [ |
||
246 | 'user' => 2, |
||
247 | 'date' => new \DateTime('12-04-1988'), |
||
248 | 'startTime' => '10:00', |
||
249 | 'endTime' => '19:00', |
||
250 | 'notes' => 'Some notes', |
||
251 | ], |
||
252 | null, |
||
253 | ], |
||
254 | 'space-padded-valid-input' => [ |
||
255 | [ |
||
256 | 'user' => 2, |
||
257 | 'date' => '12-04-1988', |
||
258 | 'startTime' => '07:00', |
||
259 | 'endTime' => '17:00', |
||
260 | 'notes' => ' Some notes ', |
||
261 | ], |
||
262 | [ |
||
263 | 'user' => 2, |
||
264 | 'date' => new \DateTime('12-04-1988'), |
||
265 | 'startTime' => '07:00', |
||
266 | 'endTime' => '17:00', |
||
267 | 'notes' => 'Some notes', |
||
268 | ], |
||
269 | null, |
||
270 | ], |
||
271 | 'invalid-date-format' => [ |
||
272 | [ |
||
273 | 'user' => 2, |
||
274 | 'date' => '12-not-a-month-2014', |
||
275 | 'startTime' => '07:00', |
||
276 | 'endTime' => '17:00', |
||
277 | ], |
||
278 | null, |
||
279 | [ |
||
280 | 'date' => [ |
||
281 | 'dateInvalidDate' => 'The input does not appear to be a valid date', |
||
282 | 'dateFalseFormat' => 'The input does not fit the date format \'d-m-Y\'', |
||
283 | ], |
||
284 | ], |
||
285 | ], |
||
286 | 'invalid-date' => [ |
||
287 | [ |
||
288 | 'user' => 2, |
||
289 | 'date' => 'not-a-date', |
||
290 | 'startTime' => '07:00', |
||
291 | 'endTime' => '17:00', |
||
292 | ], |
||
293 | null, |
||
294 | [ |
||
295 | 'date' => [ |
||
296 | 'dateInvalidDate' => 'The input does not appear to be a valid date', |
||
297 | ], |
||
298 | ], |
||
299 | ], |
||
300 | 'greater-than-time' => [ |
||
301 | [ |
||
302 | 'user' => 2, |
||
303 | 'date' => '12-04-1988', |
||
304 | 'startTime' => '10:01', |
||
305 | 'endTime' => '19:01', |
||
306 | ], |
||
307 | null, |
||
308 | [ |
||
309 | 'startTime' => [ |
||
310 | //'notLessThanInclusive' => 'The input is not less or equal than \'10:00\'', |
||
311 | 'dateStepNotStep' => 'The input is not a valid step', |
||
312 | ], |
||
313 | 'endTime' => [ |
||
314 | //'notLessThanInclusive' => 'The input is not less or equal than \'19:00\'', |
||
315 | 'dateStepNotStep' => 'The input is not a valid step', |
||
316 | ], |
||
317 | ], |
||
318 | ], |
||
319 | 'invalid-time' => [ |
||
320 | [ |
||
321 | 'user' => 2, |
||
322 | 'date' => '12-04-1988', |
||
323 | 'startTime' => 'not-a-time', |
||
324 | 'endTime' => 'not-a-time', |
||
325 | ], |
||
326 | null, |
||
327 | [ |
||
328 | 'startTime' => [ |
||
329 | 'dateInvalidDate' => 'The input does not appear to be a valid date', |
||
330 | //'notLessThanInclusive' => 'The input is not less or equal than \'10:00\'', |
||
331 | ], |
||
332 | 'endTime' => [ |
||
333 | 'dateInvalidDate' => 'The input does not appear to be a valid date', |
||
334 | //'notLessThanInclusive' => 'The input is not less or equal than \'19:00\'', |
||
335 | ], |
||
336 | ], |
||
337 | ], |
||
338 | 'message-to-long' => [ |
||
339 | [ |
||
340 | 'user' => 2, |
||
341 | 'date' => '12-04-1988', |
||
342 | 'startTime' => '09:00', |
||
343 | 'endTime' => '17:00', |
||
344 | 'notes' => $this->getLongString() |
||
345 | ], |
||
346 | null, |
||
347 | [ |
||
348 | 'notes' => [ |
||
349 | 'stringLengthTooLong' => 'The input is more than 512 characters long', |
||
350 | ], |
||
351 | ], |
||
352 | ], |
||
353 | 'invalid-time-step' => [ |
||
354 | [ |
||
355 | 'user' => 2, |
||
356 | 'date' => '12-04-1988', |
||
357 | 'startTime' => '09:04', |
||
358 | 'endTime' => '17:07', |
||
359 | ], |
||
360 | null, |
||
361 | [ |
||
362 | 'startTime' => [ |
||
363 | 'dateStepNotStep' => 'The input is not a valid step', |
||
364 | ], |
||
365 | 'endTime' => [ |
||
366 | 'dateStepNotStep' => 'The input is not a valid step', |
||
367 | ], |
||
368 | ], |
||
369 | ], |
||
370 | 'required-fields' => [ |
||
371 | [ |
||
372 | ], |
||
373 | null, |
||
374 | [ |
||
375 | 'user' => [ |
||
376 | 'isEmpty' => 'Value is required and can\'t be empty', |
||
377 | ], |
||
378 | 'date' => [ |
||
379 | 'isEmpty' => 'Value is required and can\'t be empty', |
||
380 | ], |
||
381 | 'startTime' => [ |
||
382 | 'isEmpty' => 'Value is required and can\'t be empty', |
||
383 | ], |
||
384 | 'endTime' => [ |
||
385 | 'isEmpty' => 'Value is required and can\'t be empty', |
||
386 | ], |
||
387 | ], |
||
388 | ], |
||
389 | ]; |
||
390 | } |
||
391 | |||
435 |