Conditions | 1 |
Paths | 1 |
Total Lines | 214 |
Code Lines | 98 |
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 |
||
255 | public function outputData() |
||
256 | { |
||
257 | return [ |
||
258 | [ // verbose with single valid run |
||
259 | OutputInterface::VERBOSITY_VERBOSE, |
||
260 | false, |
||
261 | false, |
||
262 | [true], |
||
263 | [ |
||
264 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %'], |
||
265 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%'], |
||
266 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'], |
||
267 | ], |
||
268 | ], |
||
269 | [ // normal verbosity only writes a single line |
||
270 | OutputInterface::VERBOSITY_NORMAL, |
||
271 | false, |
||
272 | false, |
||
273 | [true], |
||
274 | [ |
||
275 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'], |
||
276 | ], |
||
277 | ], |
||
278 | [ |
||
279 | OutputInterface::VERBOSITY_NORMAL, |
||
280 | false, |
||
281 | false, |
||
282 | [true, true], |
||
283 | [ |
||
284 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'], |
||
285 | ['%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'], |
||
286 | ], |
||
287 | ], |
||
288 | [ // multiple runs with verbosity will update each item one at a time |
||
289 | OutputInterface::VERBOSITY_VERBOSE, |
||
290 | false, |
||
291 | false, |
||
292 | [true, true], |
||
293 | [ |
||
294 | [ |
||
295 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
296 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
297 | ], |
||
298 | [ |
||
299 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
300 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
301 | ], |
||
302 | [ |
||
303 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
304 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
305 | ], |
||
306 | [ |
||
307 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
308 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
309 | ], |
||
310 | [ |
||
311 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
312 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
313 | ], |
||
314 | ], |
||
315 | ], |
||
316 | [ // errors will display an error |
||
317 | OutputInterface::VERBOSITY_VERBOSE, |
||
318 | false, |
||
319 | false, |
||
320 | [false], |
||
321 | [ |
||
322 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %'], |
||
323 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%'], |
||
324 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>%'], |
||
325 | [ |
||
326 | <<<DOC |
||
327 | %The command "test" failed. |
||
328 | |||
329 | Exit Code: 1\(failed\) |
||
330 | |||
331 | Working directory: /tmp |
||
332 | |||
333 | Output: |
||
334 | ================ |
||
335 | some text |
||
336 | |||
337 | Error Output: |
||
338 | ================ |
||
339 | some error text% |
||
340 | DOC |
||
341 | , |
||
342 | ], |
||
343 | ], |
||
344 | ], |
||
345 | [ // errors will display an error |
||
346 | OutputInterface::VERBOSITY_NORMAL, |
||
347 | false, |
||
348 | false, |
||
349 | [false], |
||
350 | [ |
||
351 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>%'], |
||
352 | [ |
||
353 | <<<DOC |
||
354 | %The command "test" failed. |
||
355 | |||
356 | Exit Code: 1\(failed\) |
||
357 | |||
358 | Working directory: /tmp |
||
359 | |||
360 | Output: |
||
361 | ================ |
||
362 | some text |
||
363 | |||
364 | Error Output: |
||
365 | ================ |
||
366 | some error text% |
||
367 | DOC |
||
368 | , |
||
369 | ], |
||
370 | ], |
||
371 | ], |
||
372 | [ // multiple runs with verbosity will update each item one at a time |
||
373 | OutputInterface::VERBOSITY_VERBOSE, |
||
374 | false, |
||
375 | false, |
||
376 | [true, false], |
||
377 | [ |
||
378 | [ |
||
379 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
380 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
381 | ], |
||
382 | [ |
||
383 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
384 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
385 | ], |
||
386 | [ |
||
387 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
388 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
389 | ], |
||
390 | [ |
||
391 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
392 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
393 | ], |
||
394 | [ |
||
395 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
396 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>%', |
||
397 | ], |
||
398 | [ |
||
399 | <<<DOC |
||
400 | %The command "test" failed. |
||
401 | |||
402 | Exit Code: 1\(failed\) |
||
403 | |||
404 | Working directory: /tmp |
||
405 | |||
406 | Output: |
||
407 | ================ |
||
408 | some text |
||
409 | |||
410 | Error Output: |
||
411 | ================ |
||
412 | some error text% |
||
413 | DOC |
||
414 | , |
||
415 | ], |
||
416 | ], |
||
417 | ], |
||
418 | [ // include output |
||
419 | OutputInterface::VERBOSITY_VERBOSE, |
||
420 | true, |
||
421 | false, |
||
422 | [true], |
||
423 | [ |
||
424 | ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %'], |
||
425 | ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏] some text%'], |
||
426 | ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info> some text%'], |
||
427 | ], |
||
428 | ], |
||
429 | [ // include a summary |
||
430 | OutputInterface::VERBOSITY_VERBOSE, |
||
431 | false, |
||
432 | true, |
||
433 | [true, true], |
||
434 | [ |
||
435 | [ |
||
436 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
437 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
438 | '%^$%', |
||
439 | ], |
||
440 | [ |
||
441 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
442 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
443 | '%<comment>Total</comment>: 2, <comment>Running</comment>: 2, <comment>Waiting</comment>: 0%', |
||
444 | ], |
||
445 | [ |
||
446 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
447 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
448 | '%<comment>Total</comment>: 2, <comment>Running</comment>: 2, <comment>Waiting</comment>: 0%', |
||
449 | ], |
||
450 | [ |
||
451 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
452 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
453 | '%<comment>Total</comment>: 2, <comment>Running</comment>: 2, <comment>Waiting</comment>: 0%', |
||
454 | ], |
||
455 | [ |
||
456 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
457 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
458 | '%<comment>Total</comment>: 2, <comment>Running</comment>: 2, <comment>Waiting</comment>: 0%', |
||
459 | ], |
||
460 | [ |
||
461 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
462 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
463 | '%^$%', |
||
464 | ], |
||
465 | ], |
||
466 | ], |
||
467 | ]; |
||
468 | } |
||
469 | } |
||
470 |