| Conditions | 10 |
| Paths | 16 |
| Total Lines | 43 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 declare(strict_types=1); |
||
| 96 | protected function initialize(InputInterface $input, OutputInterface $output): void |
||
| 97 | { |
||
| 98 | $repositories = []; |
||
| 99 | $this->output = new SymfonyStyle($input, $output); |
||
| 100 | $config = new Config(\rtrim($input->getOption('path') ?? $this->rootPath, '\/'), $input->getOption('cache'), $input->getOption('clean')); |
||
| 101 | $exclusive = $input->getOption('only'); |
||
| 102 | |||
| 103 | if (empty($jobWorkers = $config['workers'][$stage = $input->getArgument('job')] ?? [])) { |
||
| 104 | $this->output->error(\sprintf('There are workflow workers registered. Be sure to add them to "%s"', $stage)); |
||
| 105 | |||
| 106 | return; |
||
| 107 | } |
||
| 108 | |||
| 109 | foreach ($jobWorkers as $offset => $worker) { |
||
| 110 | $worker = $worker::configure($this); |
||
| 111 | |||
| 112 | if ($worker instanceof PriorityInterface && $offset !== $worker->getPriority()) { |
||
| 113 | $this->output->error(\sprintf( |
||
| 114 | 'The "%s" worker must indexed "%s" and not "%s" in stage "%s"', |
||
| 115 | $worker::class, |
||
| 116 | $worker->getPriority(), |
||
| 117 | $offset, |
||
| 118 | $stage |
||
| 119 | )); |
||
| 120 | break; |
||
| 121 | } |
||
| 122 | |||
| 123 | $this->workers[] = $worker; |
||
| 124 | } |
||
| 125 | |||
| 126 | foreach ($config['repositories'] as $repoName => $data) { |
||
| 127 | if ($exclusive && !\in_array($repoName, $exclusive, true)) { |
||
| 128 | continue; |
||
| 129 | } |
||
| 130 | |||
| 131 | if (\in_array($stage, $data['workers'] ?? ['main'], true)) { |
||
| 132 | $repositories[] = [$data['url'], $repoName, $data['path'], $data['merge'] ? 'true' : 'false']; |
||
| 133 | } |
||
| 134 | } |
||
| 135 | |||
| 136 | $this->output->table(['Repo Url', 'Repo Name', 'Repo Path', 'Allow Merge'], $repositories); |
||
| 137 | $this->monorepo = new Monorepo($config, $output->getVerbosity(), $repositories); |
||
| 138 | $input->bind($this->getDefinition()); |
||
| 139 | } |
||
| 141 |