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