Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 6.7968 |
Changes | 5 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
25 | 12 | public function prune(Auditable $model): bool |
|
26 | { |
||
27 | 12 | if (($threshold = $model->getAuditThreshold()) > 0) { |
|
28 | $forRemoval = $model->audits() |
||
29 | ->latest() |
||
30 | ->get() |
||
31 | ->slice($threshold) |
||
32 | ->pluck('id'); |
||
33 | |||
34 | if (!$forRemoval->isEmpty()) { |
||
35 | return $model->audits() |
||
36 | ->whereIn('id', $forRemoval) |
||
37 | ->delete() > 0; |
||
38 | } |
||
39 | } |
||
40 | |||
41 | 12 | return false; |
|
42 | } |
||
44 |