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