| Conditions | 12 |
| Paths | 18 |
| Total Lines | 50 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 29 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 30 | { |
||
| 31 | $set = false; |
||
| 32 | |||
| 33 | $this->initConfiguration($input->getOption('configFile')); |
||
| 34 | |||
| 35 | if ($input->getOption('remote')) { |
||
| 36 | $value = $input->getOption('remote'); |
||
| 37 | |||
| 38 | if ($value == 'on' || $value == 'true' || $value === true) { |
||
| 39 | $value = true; |
||
| 40 | } else { |
||
| 41 | $value = false; |
||
| 42 | } |
||
| 43 | |||
| 44 | $output->writeln(""); |
||
| 45 | $output->writeln('Remote command mode: <info>' . ($value ? 'on' : 'off') . '</info>'); |
||
| 46 | |||
| 47 | $this->setRemoteEnabled($value); |
||
| 48 | |||
| 49 | $set = true; |
||
| 50 | } |
||
| 51 | |||
| 52 | if ($input->getOption('logfile')) { |
||
| 53 | $value = $input->getOption('logfile'); |
||
| 54 | |||
| 55 | if ($value == 'on' || $value == 'true' || $value === true) { |
||
| 56 | $value = true; |
||
| 57 | } else { |
||
| 58 | $value = false; |
||
| 59 | } |
||
| 60 | |||
| 61 | $output->writeln(""); |
||
| 62 | $output->writeln('Logfile mode: <info>' . ($value ? 'on' : 'off') . '</info>'); |
||
| 63 | |||
| 64 | $this->setLogfileEnabled($value); |
||
| 65 | |||
| 66 | $set = true; |
||
| 67 | } |
||
| 68 | |||
| 69 | if (!$set) { |
||
| 70 | $output->writeln('<error>Configuration was not changed. Please provide at least one flag.</error>'); |
||
| 71 | } else { |
||
| 72 | $output->writeln(""); |
||
| 73 | $this->getApplication()->find('collect')->run(new ArrayInput([]), $output); |
||
| 74 | $output->writeln(""); |
||
| 75 | $output->writeln('If you are running inventorio via SystemD please call: <info>systemctl restart inventorio.service</info>'); |
||
| 76 | } |
||
| 77 | |||
| 78 | return Command::SUCCESS; |
||
| 79 | } |
||
| 82 |