| Conditions | 8 |
| Paths | 107 |
| Total Lines | 56 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 1 | 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 |
||
| 15 | public function execute() |
||
| 16 | { |
||
| 17 | if ($this->input->getOption('noDownload')) { |
||
| 18 | return; |
||
| 19 | } |
||
| 20 | |||
| 21 | try { |
||
| 22 | $this->checkMagentoConnectCredentials($this->output); |
||
| 23 | |||
| 24 | $package = $this->config['magentoVersionData']; |
||
| 25 | $this->config->setArray('magentoPackage', $package); |
||
| 26 | |||
| 27 | if (file_exists($this->config->getString('installationFolder') . '/app/etc/env.php')) { |
||
| 28 | $this->output->writeln('<error>A magento installation already exists in this folder </error>'); |
||
| 29 | return; |
||
| 30 | } |
||
| 31 | |||
| 32 | $args = [ |
||
| 33 | $this->config['composer_bin'], |
||
| 34 | 'create-project', |
||
| 35 | ]; |
||
| 36 | |||
| 37 | // Add composer options |
||
| 38 | foreach ($package['options'] as $optionName => $optionValue) { |
||
| 39 | $args[] = '--' . $optionName . ($optionValue === true ? '' : '=' . $optionValue); |
||
| 40 | } |
||
| 41 | |||
| 42 | // Add arguments |
||
| 43 | $args[] = $package['package']; |
||
| 44 | $args[] = $this->config->getString('installationFolder'); |
||
| 45 | $args[] = $package['version']; |
||
| 46 | |||
| 47 | if (OutputInterface::VERBOSITY_VERBOSE <= $this->output->getVerbosity()) { |
||
| 48 | $args[] = '-vvv'; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @TODO use composer helper |
||
| 53 | */ |
||
| 54 | $processBuilder = new ProcessBuilder($args); |
||
| 55 | |||
| 56 | $process = $processBuilder->getProcess(); |
||
| 57 | $process->setInput($this->input); |
||
| 58 | if (OutputInterface::VERBOSITY_VERBOSE <= $this->output->getVerbosity()) { |
||
| 59 | $this->output->writeln($process->getCommandLine()); |
||
| 60 | } |
||
| 61 | |||
| 62 | $process->setTimeout(86400); |
||
| 63 | $process->start(); |
||
| 64 | $process->wait(function ($type, $buffer) { |
||
| 65 | $this->output->write($buffer, false, OutputInterface::OUTPUT_RAW); |
||
| 66 | }); |
||
| 67 | } catch (\Exception $e) { |
||
| 68 | $this->output->writeln('<error>' . $e->getMessage() . '</error>'); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 167 |