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