| 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 |
||
| 57 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 58 | { |
||
| 59 | $format = $this->stringOption(input: $input, name: 'format'); |
||
| 60 | |||
| 61 | $io = new SymfonyStyle(input: $input, output: $output); |
||
| 62 | |||
| 63 | $users = $this->user_service->all()->sort(callback: fn ($a, $b) => $a->id() <=> $b->id()); |
||
| 64 | |||
| 65 | $headers = ['ID', 'Username', 'Real Name', 'Email', 'Admin', 'Approved', 'Verified', 'Language', 'Timezone', 'Contact', 'Registered', 'Last login']; |
||
| 66 | |||
| 67 | $rows = $users->map(callback: fn (User $user): array => [ |
||
| 68 | 'id' => $user->id(), |
||
| 69 | 'username' => $user->userName(), |
||
| 70 | 'real_name' => $user->realName(), |
||
| 71 | 'email' => $user->email(), |
||
| 72 | 'admin' => $user->getPreference(setting_name: UserInterface::PREF_IS_ADMINISTRATOR) ? 'yes' : 'no', |
||
| 73 | 'approved' => $user->getPreference(setting_name: UserInterface::PREF_IS_ACCOUNT_APPROVED) ? 'yes' : 'no', |
||
| 74 | 'verified' => $user->getPreference(setting_name: UserInterface::PREF_IS_EMAIL_VERIFIED) ? 'yes' : 'no', |
||
| 75 | 'language' => $user->getPreference(setting_name: UserInterface::PREF_LANGUAGE), |
||
| 76 | 'timezone' => $user->getPreference(setting_name: UserInterface::PREF_TIME_ZONE), |
||
| 77 | 'contact' => $user->getPreference(setting_name: UserInterface::PREF_CONTACT_METHOD), |
||
| 78 | 'registered' => $this->formatTimestamp(timestamp: (int) $user->getPreference(setting_name: UserInterface::PREF_TIMESTAMP_REGISTERED)), |
||
| 79 | 'last_login' => $this->formatTimestamp(timestamp: (int) $user->getPreference(setting_name: UserInterface::PREF_TIMESTAMP_ACTIVE)), |
||
| 80 | ]) |
||
| 81 | ->values() |
||
| 82 | ->all(); |
||
| 83 | |||
| 84 | switch ($format) { |
||
| 85 | case 'table': |
||
| 86 | $table = new Table(output: $output); |
||
| 87 | $table->setHeaders(headers: $headers); |
||
| 88 | $table->setRows(rows: $rows); |
||
| 89 | $table->render(); |
||
| 90 | break; |
||
| 91 | |||
| 92 | case 'csv': |
||
| 93 | $output->writeln(messages: $this->quoteCsvRow(columns: $headers)); |
||
| 94 | |||
| 95 | foreach ($rows as $row) { |
||
| 96 | $output->writeln(messages: $this->quoteCsvRow(columns: $row)); |
||
| 97 | } |
||
| 98 | break; |
||
| 99 | |||
| 100 | case 'json': |
||
| 101 | $output->writeln(messages: json_encode(value: $rows, flags: JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)); |
||
| 102 | break; |
||
| 103 | |||
| 104 | default: |
||
| 105 | $io->error(message: 'Invalid format: ‘' . $format . '’'); |
||
| 106 | |||
| 107 | return self::FAILURE; |
||
| 108 | } |
||
| 109 | |||
| 110 | return self::SUCCESS; |
||
| 111 | } |
||
| 137 |
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