| Conditions | 8 |
| Paths | 4 |
| Total Lines | 54 |
| Code Lines | 38 |
| 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 |
||
| 58 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 59 | { |
||
| 60 | $format = $input->getOption(name: 'format'); |
||
| 61 | |||
| 62 | $io = new SymfonyStyle(input: $input, output: $output); |
||
| 63 | |||
| 64 | $users = $this->user_service->all()->sort(callback: fn ($a, $b) => $a->id() <=> $b->id()); |
||
| 65 | |||
| 66 | $headers = ['ID', 'Username', 'Real Name', 'Email', 'Admin', 'Approved', 'Verified', 'Language', 'Timezone', 'Contact', 'Registered', 'Last login']; |
||
| 67 | |||
| 68 | $rows = $users->map(callback: fn (User $user): array => [ |
||
| 69 | 'id' => $user->id(), |
||
| 70 | 'username' => $user->userName(), |
||
| 71 | 'real_name' => $user->realName(), |
||
| 72 | 'email' => $user->email(), |
||
| 73 | 'admin' => $user->getPreference(setting_name: UserInterface::PREF_IS_ADMINISTRATOR) ? 'yes' : 'no', |
||
| 74 | 'approved' => $user->getPreference(setting_name: UserInterface::PREF_IS_ACCOUNT_APPROVED) ? 'yes' : 'no', |
||
| 75 | 'verified' => $user->getPreference(setting_name: UserInterface::PREF_IS_EMAIL_VERIFIED) ? 'yes' : 'no', |
||
| 76 | 'language' => $user->getPreference(setting_name: UserInterface::PREF_LANGUAGE), |
||
| 77 | 'timezone' => $user->getPreference(setting_name: UserInterface::PREF_TIME_ZONE), |
||
| 78 | 'contact' => $user->getPreference(setting_name: UserInterface::PREF_CONTACT_METHOD), |
||
| 79 | 'registered' => $this->formatTimestamp(timestamp: (int) $user->getPreference(setting_name: UserInterface::PREF_TIMESTAMP_REGISTERED)), |
||
| 80 | 'last_login' => $this->formatTimestamp(timestamp: (int) $user->getPreference(setting_name: UserInterface::PREF_TIMESTAMP_ACTIVE)), |
||
| 81 | ]) |
||
| 82 | ->values() |
||
| 83 | ->all(); |
||
| 84 | |||
| 85 | switch ($format) { |
||
| 86 | case 'table': |
||
| 87 | $table = new Table(output: $output); |
||
| 88 | $table->setHeaders(headers: $headers); |
||
| 89 | $table->setRows(rows: $rows); |
||
| 90 | $table->render(); |
||
| 91 | break; |
||
| 92 | |||
| 93 | case 'csv': |
||
| 94 | $output->writeln(messages: $this->quoteCsvRow(columns: $headers)); |
||
| 95 | |||
| 96 | foreach ($rows as $row) { |
||
| 97 | $output->writeln(messages: $this->quoteCsvRow(columns: $row)); |
||
| 98 | } |
||
| 99 | break; |
||
| 100 | |||
| 101 | case 'json': |
||
| 102 | $output->writeln(messages: json_encode(value: $rows, flags: JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)); |
||
| 103 | break; |
||
| 104 | |||
| 105 | default: |
||
| 106 | $io->error(message: 'Invalid format: ‘' . $format . '’'); |
||
| 107 | |||
| 108 | return Command::FAILURE; |
||
| 109 | } |
||
| 110 | |||
| 111 | return Command::SUCCESS; |
||
| 112 | } |
||
| 139 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths