Conditions | 11 |
Paths | 52 |
Total Lines | 57 |
Code Lines | 36 |
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 |
||
30 | protected function execute(InputInterface $input, OutputInterface $output) |
||
31 | { |
||
32 | if ($output->isDebug()) { |
||
33 | $output->write(['Running from: <info>', PROJECT_ROOT, '</info>']); |
||
34 | $output->writeln(''); |
||
35 | } |
||
36 | |||
37 | if (extension_loaded('xdebug')) { |
||
38 | $output->writeln( |
||
39 | sprintf( |
||
40 | '<bg=yellow;fg=black;>%s</>', |
||
41 | 'Xdebug is enabled; performance will likely be affected.' |
||
42 | ) |
||
43 | ); |
||
44 | } |
||
45 | |||
46 | $event = $input->getOption('event'); |
||
47 | $actions = $this->config->get($event); |
||
48 | |||
49 | if (!empty($actions)) { |
||
50 | // See https://github.com/symfony/symfony/pull/10356 for multiple bars |
||
51 | $progress = !$input->hasOption('no-progress') |
||
52 | ? new ProgressBar($output, count($actions)) |
||
53 | : null; |
||
54 | if ($progress) { |
||
55 | $progress->start(); |
||
56 | $output->write("\n"); |
||
57 | } |
||
58 | |||
59 | foreach ($actions as $action) { |
||
60 | if ($progress) { |
||
61 | $output->write("\033[1A"); |
||
62 | $progress->setMessage('Running "' . $action->getName() . '".'); |
||
63 | $progress->advance(); |
||
64 | $output->write("\n"); |
||
65 | } else { |
||
66 | $output->writeln('Running <info>"' . $action->getName() . '"</info>...'); |
||
67 | } |
||
68 | |||
69 | try { |
||
70 | $action->execute($input, $output); |
||
71 | } catch (\Exception $ex) { |
||
72 | $this->getApplication()->renderException($ex, $output); |
||
73 | if (!($ex instanceof RecoverableException)) { |
||
74 | return 1; |
||
75 | } |
||
76 | } |
||
77 | } |
||
78 | |||
79 | if ($progress) { |
||
80 | $progress->finish(); |
||
81 | } |
||
82 | $output->writeln('Done.'); |
||
83 | } |
||
84 | |||
85 | return 0; |
||
86 | } |
||
87 | } |
||
88 |