Conditions | 10 |
Paths | 40 |
Total Lines | 37 |
Code Lines | 24 |
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 |
||
19 | public static function collect(InputInterface $input, OutputInterface $output): array |
||
20 | { |
||
21 | $arguments = []; |
||
22 | foreach ($input->getOptions() as $name => $value) { |
||
23 | if (!$input->getOption($name)) { |
||
24 | continue; |
||
25 | } |
||
26 | if ($name === 'file') { |
||
27 | $arguments[] = "--file"; |
||
28 | $arguments[] = ltrim($value, '='); |
||
29 | continue; |
||
30 | } |
||
31 | if (in_array($name, ['verbose'], true)) { |
||
32 | continue; |
||
33 | } |
||
34 | if (!is_array($value)) { |
||
35 | $value = [$value]; |
||
36 | } |
||
37 | foreach ($value as $v) { |
||
38 | if (is_bool($v)) { |
||
39 | $arguments[] = "--$name"; |
||
40 | continue; |
||
41 | } |
||
42 | |||
43 | $arguments[] = "--$name"; |
||
44 | $arguments[] = $v; |
||
45 | } |
||
46 | } |
||
47 | |||
48 | if ($output->isDecorated()) { |
||
49 | $arguments[] = '--decorated'; |
||
50 | } |
||
51 | $verbosity = self::verbosity($output->getVerbosity()); |
||
52 | if (!empty($verbosity)) { |
||
53 | $arguments[] = $verbosity; |
||
54 | } |
||
55 | return $arguments; |
||
56 | } |
||
76 |