Conditions | 10 |
Paths | 51 |
Total Lines | 64 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
93 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
94 | { |
||
95 | $io = new SymfonyStyle($input, $output); |
||
96 | $io->title($this->translator->trans('Zikula Installer Script')); |
||
97 | |||
98 | if (true === $this->installed) { |
||
99 | $io->error($this->translator->trans('Zikula already appears to be installed.')); |
||
100 | |||
101 | return 1; |
||
102 | } |
||
103 | |||
104 | $warnings = $this->controllerHelper->initPhp(); |
||
105 | if (!empty($warnings)) { |
||
106 | $this->printWarnings($output, $warnings); |
||
107 | |||
108 | return 2; |
||
109 | } |
||
110 | $checks = $this->controllerHelper->requirementsMet(); |
||
111 | if (true !== $checks) { |
||
|
|||
112 | $this->printRequirementsWarnings($output, $checks); |
||
113 | |||
114 | return 2; |
||
115 | } |
||
116 | |||
117 | if ($input->isInteractive()) { |
||
118 | $io->comment($this->translator->trans('Configuring Zikula installation in %env% environment.', ['%env%' => $this->kernel->getEnvironment()])); |
||
119 | $io->comment($this->translator->trans('Please follow the instructions to install Zikula %version%.', ['%version%' => ZikulaKernel::VERSION])); |
||
120 | } |
||
121 | |||
122 | // get the settings from user input |
||
123 | $settings = $this->doLocale($input, $output, $io); |
||
124 | $settings = array_merge($settings, $this->doRequestContext($input, $output, $io)); |
||
125 | if (!$this->doDBCreds($input, $output, $io)) { |
||
126 | $io->error($this->translator->trans('Cannot write database DSN to %file% file.', ['%file%' => '/.env.local'])); |
||
127 | } |
||
128 | if (!$this->doMailer($input, $output, $io)) { |
||
129 | $io->error($this->translator->trans('Cannot write mailer DSN to %file% file.', ['%file%' => '/.env.local'])); |
||
130 | } |
||
131 | $settings = array_merge($settings, $this->doAdmin($input, $output, $io)); |
||
132 | |||
133 | if ($input->isInteractive()) { |
||
134 | $io->success($this->translator->trans('Configuration successful. Please verify your parameters below:')); |
||
135 | $io->comment($this->translator->trans('(Admin credentials have been encoded to make them json-safe.)')); |
||
136 | } |
||
137 | |||
138 | $this->printSettings($settings, $io); |
||
139 | $io->newLine(); |
||
140 | |||
141 | if ($input->isInteractive()) { |
||
142 | $confirmation = $io->confirm($this->translator->trans('Start installation?'), true); |
||
143 | |||
144 | if (!$confirmation) { |
||
145 | $io->error($this->translator->trans('Installation aborted')); |
||
146 | |||
147 | return 3; |
||
148 | } |
||
149 | } |
||
150 | |||
151 | // write parameters into config/services_custom.yaml and env vars into .env.local |
||
152 | $this->parameterHelper->initializeParameters($settings); |
||
153 | |||
154 | $io->success($this->translator->trans('First stage of installation complete. Run `php bin/console zikula:install:finish` to complete the installation.')); |
||
155 | |||
156 | return 0; |
||
157 | } |
||
225 |