| Conditions | 9 |
| Paths | 24 |
| Total Lines | 52 |
| 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 |
||
| 48 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 49 | { |
||
| 50 | $questionHelper = $this->getHelperSet()->get('question'); |
||
| 51 | |||
| 52 | $this->detectMagento($output); |
||
| 53 | |||
| 54 | $updateEnvQuestion = new ConfirmationQuestion( |
||
| 55 | '<question>env file found. Do you want to update it?</question> <comment>[Y/n]</comment> ', |
||
| 56 | true |
||
| 57 | ); |
||
| 58 | |||
| 59 | $envFilePath = $this->getApplication()->getMagentoRootFolder() . '/app/etc/env.php'; |
||
| 60 | |||
| 61 | if (file_exists($envFilePath) && $questionHelper->ask($input, $output, $updateEnvQuestion)) { |
||
| 62 | $envConfig = include $envFilePath; |
||
| 63 | } else { |
||
| 64 | $envConfig = include __DIR__ . '/stubs/env.php'; |
||
| 65 | } |
||
| 66 | |||
| 67 | $env = new Dot($envConfig); |
||
| 68 | |||
| 69 | $iterator = new RecursiveIteratorIterator( |
||
| 70 | new RecursiveArrayIterator($env->all()), |
||
| 71 | RecursiveIteratorIterator::SELF_FIRST |
||
| 72 | ); |
||
| 73 | |||
| 74 | foreach ($iterator as $default) { |
||
| 75 | if (!$iterator->hasChildren()) { |
||
|
|
|||
| 76 | for ($p = [], $i = 0, $z = $iterator->getDepth(); $i <= $z; $i++) { |
||
| 77 | $p[] = $iterator->getSubIterator($i)->key(); |
||
| 78 | } |
||
| 79 | |||
| 80 | $path = implode('.', $p); |
||
| 81 | $default = $this->getDefaultValue($path, $default); |
||
| 82 | $question = new Question( |
||
| 83 | '<question>' . $path . '</question> <comment>[' . $default . ']</comment> ', |
||
| 84 | $default |
||
| 85 | ); |
||
| 86 | |||
| 87 | $newValue = $questionHelper->ask($input, $output, $question); |
||
| 88 | $env->set($path, $newValue); |
||
| 89 | } |
||
| 90 | } |
||
| 91 | |||
| 92 | if (!file_exists('app/etc')) { |
||
| 93 | if (!mkdir('app/etc', 0777, true) && !is_dir('app/etc')) { |
||
| 94 | throw new \RuntimeException(sprintf('Directory "%s" was not created', 'app/etc')); |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | file_put_contents($envFilePath, "<?php\n\nreturn " . EnvHelper::exportVariable($env->all()) . ";\n"); |
||
| 99 | } |
||
| 100 | |||
| 115 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.