We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 8 |
| Paths | 18 |
| Total Lines | 60 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 110 | protected function outputSummary(string $majorVersion, array $results): int |
||
| 111 | { |
||
| 112 | $format = $this->outputFormat(); |
||
| 113 | |||
| 114 | $hasFailure = collect($results)->contains(function ($entry) { |
||
| 115 | /** @var StepResult $result */ |
||
| 116 | $result = $entry['result']; |
||
| 117 | |||
| 118 | return $result->status->isFailure(); |
||
| 119 | }); |
||
| 120 | |||
| 121 | $warnings = collect($results)->filter(function ($entry) { |
||
| 122 | /** @var StepResult $result */ |
||
| 123 | $result = $entry['result']; |
||
| 124 | |||
| 125 | return $result->status === StepStatus::Warning; |
||
| 126 | }); |
||
| 127 | |||
| 128 | if ($format === 'json') { |
||
| 129 | $payload = [ |
||
| 130 | 'version' => $majorVersion, |
||
| 131 | 'results' => collect($results)->map(function ($entry) { |
||
| 132 | /** @var StepResult $result */ |
||
| 133 | $result = $entry['result']; |
||
| 134 | |||
| 135 | return [ |
||
| 136 | 'step' => $entry['step'], |
||
| 137 | 'status' => $result->status->value, |
||
| 138 | 'summary' => $result->summary, |
||
| 139 | 'details' => $result->details, |
||
| 140 | ]; |
||
| 141 | })->values()->all(), |
||
| 142 | ]; |
||
| 143 | |||
| 144 | $this->newLine(); |
||
| 145 | $this->line(json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
||
| 146 | |||
| 147 | return $hasFailure ? Command::FAILURE : Command::SUCCESS; |
||
| 148 | } |
||
| 149 | |||
| 150 | $this->newLine(); |
||
| 151 | $this->infoBlock('Summary', 'done'); |
||
| 152 | |||
| 153 | $this->note(sprintf('Checked %d upgrade steps.', count($results)), 'gray'); |
||
| 154 | |||
| 155 | if ($hasFailure) { |
||
| 156 | $this->note('At least one step reported a failure. Review the messages above before continuing.', 'red', 'red'); |
||
| 157 | } |
||
| 158 | |||
| 159 | if ($warnings->isNotEmpty()) { |
||
| 160 | $this->note(sprintf('%d step(s) reported warnings.', $warnings->count()), 'yellow', 'yellow'); |
||
| 161 | } |
||
| 162 | |||
| 163 | if (! $hasFailure && $warnings->isEmpty()) { |
||
| 164 | $this->note('All checks passed, you are ready to continue with the manual steps from the upgrade guide.', 'green', 'green'); |
||
| 165 | } |
||
| 166 | |||
| 167 | $this->newLine(); |
||
| 168 | |||
| 169 | return $hasFailure ? Command::FAILURE : Command::SUCCESS; |
||
| 170 | } |
||
| 243 |