| Conditions | 6 |
| Paths | 6 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | public function handle(Filesystem $filesystem) |
||
| 42 | { |
||
| 43 | if (! $this->confirmToProceed('Application In Production! Will be deleted all log files from storage/log folder!')) { |
||
| 44 | return; |
||
| 45 | } |
||
| 46 | |||
| 47 | $logFiles = $filesystem->allFiles(storage_path('logs')); |
||
| 48 | if (! $logFiles) { |
||
|
|
|||
| 49 | $this->comment('Log files does not found in path ' . storage_path('logs')); |
||
| 50 | |||
| 51 | return; |
||
| 52 | } |
||
| 53 | |||
| 54 | foreach ($logFiles as $file) { |
||
| 55 | if ($file->getExtension() !== 'log') { |
||
| 56 | continue; |
||
| 57 | } |
||
| 58 | |||
| 59 | $status = $filesystem->delete($file->getRealPath()); |
||
| 60 | if ($status) { |
||
| 61 | $this->info('Successfully deleted: ' . $file); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.