We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 |
| Paths | 24 |
| Total Lines | 54 |
| Code Lines | 29 |
| 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 |
||
| 24 | public function run(): StepResult |
||
| 25 | { |
||
| 26 | $issues = []; |
||
| 27 | $checkedAny = false; |
||
| 28 | |||
| 29 | foreach ($this->operationFiles as $filename) { |
||
| 30 | $relativePath = 'config/backpack/operations/'.$filename; |
||
| 31 | |||
| 32 | if (! $this->context()->fileExists($relativePath)) { |
||
| 33 | continue; |
||
| 34 | } |
||
| 35 | |||
| 36 | $checkedAny = true; |
||
| 37 | |||
| 38 | $publishedConfig = $this->loadConfigArray($this->context()->basePath($relativePath)); |
||
| 39 | $packageConfig = $this->loadConfigArray($this->packageConfigPath($filename)); |
||
| 40 | |||
| 41 | if ($publishedConfig === null || $packageConfig === null) { |
||
| 42 | continue; |
||
| 43 | } |
||
| 44 | |||
| 45 | $missingKeys = array_diff( |
||
| 46 | $this->flattenKeys($packageConfig), |
||
| 47 | $this->flattenKeys($publishedConfig) |
||
| 48 | ); |
||
| 49 | |||
| 50 | if (! empty($missingKeys)) { |
||
| 51 | sort($missingKeys); |
||
| 52 | |||
| 53 | $issues[] = sprintf('Add the missing keys to %s:', $relativePath); |
||
| 54 | |||
| 55 | $preview = array_slice($missingKeys, 0, 10); |
||
| 56 | |||
| 57 | foreach ($preview as $key) { |
||
| 58 | $issues[] = "- {$key}"; |
||
| 59 | } |
||
| 60 | |||
| 61 | if (count($missingKeys) > count($preview)) { |
||
| 62 | $issues[] = sprintf('… %d more key(s) omitted.', count($missingKeys) - count($preview)); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 | |||
| 67 | if (! $checkedAny) { |
||
| 68 | return StepResult::skipped('Operation config files are not published.'); |
||
| 69 | } |
||
| 70 | |||
| 71 | if (empty($issues)) { |
||
| 72 | return StepResult::success('Published operation config files include the latest options.'); |
||
| 73 | } |
||
| 74 | |||
| 75 | return StepResult::warning( |
||
| 76 | 'Copy the new configuration options into your published operation config files.', |
||
| 77 | $issues |
||
| 78 | ); |
||
| 126 |