| Conditions | 18 |
| Paths | 108 |
| Total Lines | 76 |
| Code Lines | 44 |
| 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 |
||
| 30 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 31 | { |
||
| 32 | $set = false; |
||
| 33 | |||
| 34 | $this->initConfiguration($input->getOption('configFile')); |
||
| 35 | |||
| 36 | if ($input->getOption('remote')) { |
||
| 37 | $value = $input->getOption('remote'); |
||
| 38 | |||
| 39 | if ($value == 'on' || $value == 'true' || $value === true) { |
||
| 40 | $value = true; |
||
| 41 | } else { |
||
| 42 | $value = false; |
||
| 43 | } |
||
| 44 | |||
| 45 | $output->writeln(""); |
||
| 46 | $output->writeln('Remote command mode: <info>' . ($value ? 'on' : 'off') . '</info>'); |
||
| 47 | |||
| 48 | $this->setRemoteEnabled($value); |
||
| 49 | |||
| 50 | $set = true; |
||
| 51 | } |
||
| 52 | |||
| 53 | if ($input->getOption('logfile')) { |
||
| 54 | $value = $input->getOption('logfile'); |
||
| 55 | |||
| 56 | if ($value == 'on' || $value == 'true' || $value === true) { |
||
| 57 | $value = true; |
||
| 58 | } else { |
||
| 59 | $value = false; |
||
| 60 | } |
||
| 61 | |||
| 62 | $output->writeln(""); |
||
| 63 | $output->writeln('Logfile mode: <info>' . ($value ? 'on' : 'off') . '</info>'); |
||
| 64 | |||
| 65 | $this->setLogfileEnabled($value); |
||
| 66 | |||
| 67 | $set = true; |
||
| 68 | } |
||
| 69 | |||
| 70 | if ($input->getOption('metrics')) { |
||
| 71 | $value = $input->getOption('metrics'); |
||
| 72 | |||
| 73 | if ($value == 'on' || $value == 'true' || $value === true) { |
||
| 74 | $value = true; |
||
| 75 | } else { |
||
| 76 | $value = false; |
||
| 77 | } |
||
| 78 | |||
| 79 | $output->writeln(""); |
||
| 80 | $output->writeln('Metrics collection mode: <info>' . ($value ? 'on' : 'off') . '</info>'); |
||
| 81 | |||
| 82 | $this->setCollectEnabled($value); |
||
| 83 | |||
| 84 | $set = true; |
||
| 85 | } |
||
| 86 | |||
| 87 | if ($input->getOption('serverApi')) { |
||
| 88 | $value = $input->getOption('serverApi'); |
||
| 89 | |||
| 90 | $output->writeln(""); |
||
| 91 | $output->writeln('Setting server API to : <info>' . $value . '</info>'); |
||
| 92 | |||
| 93 | $this->setServerApi($value); |
||
| 94 | |||
| 95 | $set = true; |
||
| 96 | } |
||
| 97 | |||
| 98 | if ($set) { |
||
| 99 | $output->writeln(""); |
||
| 100 | $this->getApplication()->find('collect')->run(new ArrayInput([]), $output); |
||
| 101 | $output->writeln(""); |
||
| 102 | $output->writeln('If you are running inventorio via SystemD please call: <info>systemctl restart inventorio.service</info>'); |
||
| 103 | } |
||
| 104 | |||
| 105 | return Command::SUCCESS; |
||
| 106 | } |
||
| 109 |