| Conditions | 9 |
| Paths | 3 |
| Total Lines | 67 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 declare(strict_types=1); |
||
| 92 | private function dryRun(InputInterface $input, OutputInterface $output): int |
||
| 93 | { |
||
| 94 | $cursor = new Cursor($output); |
||
| 95 | |||
| 96 | $io = new ShopwareStyle($input, $output); |
||
| 97 | |||
| 98 | $mediaBatches = $this->unusedMediaPurger->getNotUsedMedia( |
||
| 99 | $input->getOption('limit') ? (int) $input->getOption('limit') : 50, |
||
| 100 | $input->getOption('offset') ? (int) $input->getOption('offset') : null, |
||
| 101 | (int) $input->getOption('grace-period-days'), |
||
| 102 | $input->getOption('folder-entity'), |
||
| 103 | ); |
||
| 104 | |||
| 105 | $totalCount = 0; |
||
| 106 | $finished = $this->consumeGeneratorInBatches($mediaBatches, 20, function ($batchNum, array $medias) use ($io, $cursor, &$totalCount) { |
||
| 107 | if ($batchNum === 0 && \count($medias) === 0) { |
||
| 108 | return true; |
||
| 109 | } |
||
| 110 | |||
| 111 | if ($batchNum === 0) { |
||
| 112 | //we only clear the screen when we actually have some unused media |
||
| 113 | $cursor->clearScreen(); |
||
| 114 | } |
||
| 115 | |||
| 116 | $totalCount += \count($medias); |
||
| 117 | |||
| 118 | $cursor->moveToPosition(0, 0); |
||
| 119 | $cursor->clearOutput(); |
||
| 120 | $io->title( |
||
| 121 | sprintf( |
||
| 122 | 'Files that will be deleted: Page %d. Records: %d - %d', |
||
| 123 | $batchNum + 1, |
||
| 124 | ($batchNum * 20) + 1, |
||
| 125 | $batchNum * 20 + \count($medias) |
||
| 126 | ) |
||
| 127 | ); |
||
| 128 | |||
| 129 | $io->table( |
||
| 130 | ['Filename', 'Title', 'Uploaded At', 'File Size'], |
||
| 131 | array_map( |
||
| 132 | fn (MediaEntity $media) => [ |
||
| 133 | $media->getFileNameIncludingExtension(), |
||
| 134 | $media->getTitle(), |
||
| 135 | $media->getUploadedAt()?->format('F jS, Y'), |
||
| 136 | MemorySizeCalculator::formatToBytes($media->getFileSize() ?? 0), |
||
| 137 | ], |
||
| 138 | $medias |
||
| 139 | ) |
||
| 140 | ); |
||
| 141 | |||
| 142 | if (\count($medias) < 20) { |
||
| 143 | //last batch |
||
| 144 | return true; |
||
| 145 | } |
||
| 146 | |||
| 147 | return $io->confirm('Show next page?', false); |
||
| 148 | }); |
||
| 149 | |||
| 150 | if ($totalCount === 0) { |
||
| 151 | $io->success(sprintf('There are no unused media files uploaded before the grace period of %d days.', (int) $input->getOption('grace-period-days'))); |
||
| 152 | } elseif ($finished) { |
||
| 153 | $io->success('No more files to show.'); |
||
| 154 | } else { |
||
| 155 | $io->info('Aborting.'); |
||
| 156 | } |
||
| 157 | |||
| 158 | return self::SUCCESS; |
||
| 159 | } |
||
| 190 |
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