| Conditions | 5 |
| Paths | 6 |
| Total Lines | 15 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public function cleanUpExpiredCooldowns() |
||
| 34 | { |
||
| 35 | // Get the datetime at which the cooldowns were last cleaned up |
||
| 36 | /** @var Carbon $lastDeletedAt */ |
||
| 37 | $lastDeletedAt = Cache::get('kurozora_cooldown_last_cleaned_up_at', null); |
||
| 38 | $hoursAgo = $lastDeletedAt == null ? null : $lastDeletedAt->diffInHours(now()); |
||
| 39 | |||
| 40 | // Delete the cooldowns if the last run was 24 hours ago or more |
||
| 41 | if($hoursAgo >= 24 || $hoursAgo == null) { |
||
|
|
|||
| 42 | try { |
||
| 43 | Cooldown::expired()->delete(); |
||
| 44 | } |
||
| 45 | catch(Exception $e) { } |
||
| 46 | |||
| 47 | Cache::forever('kurozora_cooldown_last_cleaned_up_at', now()); |
||
| 48 | } |
||
| 50 | } |