| Conditions | 3 |
| Paths | 2 |
| Total Lines | 34 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 2 | Features | 0 |
| 1 | <?php |
||
| 17 | public function handle() |
||
| 18 | { |
||
| 19 | $this->comment('Cleaning old incoming email logs...'); |
||
| 20 | |||
| 21 | $maxAgeInDays = config('mailbox.store_incoming_emails_for_days'); |
||
| 22 | |||
| 23 | if ($maxAgeInDays === INF) { |
||
| 24 | $this->error($this->signature.' is disabled because store_incoming_emails_for_days is set to INF.'); |
||
| 25 | |||
| 26 | return 1; |
||
| 27 | } |
||
| 28 | |||
| 29 | $cutOffDate = Carbon::now()->subDay($maxAgeInDays)->format('Y-m-d H:i:s'); |
||
|
|
|||
| 30 | |||
| 31 | /** @var InboundEmail $modelClass */ |
||
| 32 | $modelClass = config('mailbox.model'); |
||
| 33 | |||
| 34 | // chunk the deletion to avoid memory issues |
||
| 35 | |||
| 36 | $this->amountDeleted = 0; |
||
| 37 | |||
| 38 | $modelClass::where('created_at', '<', $cutOffDate) |
||
| 39 | ->select('id') |
||
| 40 | ->chunk(100, function ($models) use ($modelClass) { |
||
| 41 | foreach ($models as $model) { |
||
| 42 | $modelInstance = $modelClass::find($model->id); |
||
| 43 | $modelInstance->delete(); |
||
| 44 | $this->amountDeleted++; |
||
| 45 | } |
||
| 46 | }); |
||
| 47 | |||
| 48 | $this->info("Deleted {$this->amountDeleted} record(s) from the Mailbox logs."); |
||
| 49 | |||
| 50 | $this->comment('All done!'); |
||
| 51 | } |
||
| 53 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.