| Conditions | 14 |
| Paths | 18 |
| Total Lines | 34 |
| Code Lines | 23 |
| 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 |
||
| 36 | public function run(array $oneFileInfoArray, ?string $mode = null) |
||
| 37 | { |
||
| 38 | if ($mode !== 'add' && $mode !== 'remove' && $mode !== null) { |
||
| 39 | user_error('Mode must be either "add" or "remove" or not set at all', E_USER_ERROR); |
||
| 40 | } |
||
| 41 | $pathFromAssetsFolder = $oneFileInfoArray['Path']; |
||
| 42 | $absolutePath = $oneFileInfoArray['AbsolutePath']; |
||
| 43 | |||
| 44 | $reasonPadding = 15; // Adjust padding as needed for alignment |
||
| 45 | |||
| 46 | |||
| 47 | // Usage |
||
| 48 | if ($oneFileInfoArray['IsDir']) { |
||
| 49 | $this->logMessage('Skipping [FOLDER]', $pathFromAssetsFolder); |
||
| 50 | } elseif (!empty($oneFileInfoArray['IsResizedImage'])) { |
||
| 51 | if (file_exists($absolutePath)) { |
||
| 52 | $this->logMessage('Deleting', $pathFromAssetsFolder, 'deleted'); |
||
| 53 | if ($this->dryRun === false) { |
||
| 54 | unlink($absolutePath); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | $this->logMessage('Skipping [RESIZED IMAGE]', $pathFromAssetsFolder); |
||
| 58 | } elseif ($oneFileInfoArray['ErrorDBNotPresent'] && $mode !== 'remove') { |
||
| 59 | $this->logMessage('+++ Adding to DB', $pathFromAssetsFolder, 'created'); |
||
| 60 | if ($this->dryRun === false) { |
||
| 61 | $this->addFileToDb($oneFileInfoArray); |
||
| 62 | } |
||
| 63 | } elseif ($oneFileInfoArray['ErrorIsInFileSystem'] && $mode !== 'add') { |
||
| 64 | $this->logMessage('--- Removing from DB', $pathFromAssetsFolder, 'deleted'); |
||
| 65 | if ($this->dryRun === false) { |
||
| 66 | $this->removeFileFromDb($oneFileInfoArray); |
||
| 67 | } |
||
| 68 | } else { |
||
| 69 | $this->logMessage('Skipping [ALL OK]', $pathFromAssetsFolder); |
||
| 70 | } |
||
| 125 |
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