| Conditions | 6 |
| Paths | 11 |
| Total Lines | 51 |
| Code Lines | 30 |
| 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 |
||
| 118 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 119 | { |
||
| 120 | if (version_compare($this->installed, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION, '<')) { |
||
| 121 | $output->writeln($this->translator->trans('The currently installed version of Zikula (%currentVersion%) is too old. You must upgrade to version %minimumVersion% before you can use this upgrade.', ['%currentVersion%' => $this->installed, '%minimumVersion%' => UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION])); |
||
| 122 | |||
| 123 | return 1; |
||
| 124 | } |
||
| 125 | |||
| 126 | $io = new SymfonyStyle($input, $output); |
||
| 127 | if ($input->isInteractive()) { |
||
| 128 | $io->title($this->translator->trans('Zikula Upgrader Script')); |
||
| 129 | $io->section($this->translator->trans('*** UPGRADING TO ZIKULA CORE %version% ***', ['%version%' => ZikulaKernel::VERSION])); |
||
| 130 | $io->text($this->translator->trans('Upgrading Zikula in %env% environment.', ['%env%' => $this->kernel->getEnvironment()])); |
||
| 131 | } |
||
| 132 | |||
| 133 | $iniWarnings = $this->phpHelper->setUp(); |
||
| 134 | if (!empty($iniWarnings)) { |
||
| 135 | $this->printWarnings($output, $iniWarnings); |
||
| 136 | |||
| 137 | return 2; |
||
| 138 | } |
||
| 139 | |||
| 140 | $yamlManager = new YamlDumper($this->kernel->getProjectDir() . '/config', 'services_custom.yaml'); |
||
| 141 | $yamlManager->setParameter('upgrading', true); // tell the core that we are upgrading |
||
| 142 | |||
| 143 | $this->migrateUsers($input, $output, $io); |
||
| 144 | |||
| 145 | // get the settings from user input |
||
| 146 | $settings = $this->doLocale($input, $output, $io); |
||
| 147 | $settings = array_merge($settings, $this->doAdminLogin($input, $output, $io)); |
||
| 148 | if (false === $mailSettings = $this->doMailer($input, $output, $io)) { |
||
| 149 | $io->error($this->translator->trans('Cannot write mailer DSN to %file% file.', ['%file%' => '/.env.local'])); |
||
| 150 | } else { |
||
| 151 | $settings = array_merge($settings, $mailSettings); |
||
| 152 | } |
||
| 153 | $settings = array_merge($settings, $this->doRequestContext($input, $output, $io)); |
||
| 154 | |||
| 155 | if ($input->isInteractive()) { |
||
| 156 | $this->printSettings($settings, $io); |
||
| 157 | $io->newLine(); |
||
| 158 | } |
||
| 159 | |||
| 160 | $params = array_merge($yamlManager->getParameters(), $settings); |
||
| 161 | $yamlManager->setParameters($params); |
||
| 162 | |||
| 163 | // upgrade! |
||
| 164 | $this->stageHelper->handleAjaxStage($this->ajaxUpgraderStage, $io); |
||
| 165 | |||
| 166 | $io->success($this->translator->trans('UPGRADE SUCCESSFUL!')); |
||
| 167 | |||
| 168 | return 0; |
||
| 169 | } |
||
| 219 |