Conditions | 7 |
Paths | 8 |
Total Lines | 57 |
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 |
||
96 | protected function execute(InputInterface $input, OutputInterface $output): int { |
||
97 | $reset = $input->getOption('reset'); |
||
98 | $uninstall = $input->getOption('uninstall'); |
||
99 | |||
100 | if ($reset || $uninstall) { |
||
101 | $output->writeln(''); |
||
102 | $output->writeln(''); |
||
103 | $output->writeln( |
||
104 | '<error>WARNING! You are about to delete all data related to the Circles App!</error>' |
||
105 | ); |
||
106 | $question = new ConfirmationQuestion( |
||
107 | '<comment>Do you really want to want to reset Circle ?</comment> (y/N) ', false, '/^(y|Y)/i' |
||
108 | ); |
||
109 | |||
110 | $helper = $this->getHelper('question'); |
||
111 | if (!$helper->ask($input, $output, $question)) { |
||
112 | $output->writeln('aborted.'); |
||
113 | |||
114 | return 0; |
||
115 | } |
||
116 | |||
117 | $output->writeln(''); |
||
118 | $output->writeln('<error>WARNING! This operation is not reversible.</error>'); |
||
119 | |||
120 | $keyword = ($uninstall) ? 'uninstall' : 'reset'; |
||
121 | |||
122 | $question = new Question( |
||
123 | '<comment>Please confirm this destructive operation by typing \'' . $keyword |
||
124 | . '\'</comment>: ', '' |
||
125 | ); |
||
126 | |||
127 | $helper = $this->getHelper('question'); |
||
128 | $confirmation = $helper->ask($input, $output, $question); |
||
129 | if (strtolower($confirmation) !== strtolower($keyword)) { |
||
130 | $output->writeln('aborted.'); |
||
131 | |||
132 | return 0; |
||
133 | } |
||
134 | |||
135 | $this->coreQueryBuilder->cleanDatabase(); |
||
136 | if ($uninstall) { |
||
137 | $this->coreQueryBuilder->uninstall(); |
||
138 | } |
||
139 | |||
140 | $output->writeln('<info>' . $keyword . ' done</info>'); |
||
141 | |||
142 | return 0; |
||
143 | } |
||
144 | |||
145 | $this->maintenanceService->setOccOutput($output); |
||
146 | $this->maintenanceService->runMaintenance(); |
||
147 | |||
148 | $output->writeln(''); |
||
149 | $output->writeln('<info>done</info>'); |
||
150 | |||
151 | return 0; |
||
152 | } |
||
153 | |||
158 |