Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 3 |
Changes | 5 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
34 | 47 | public function prune(Auditable $model): bool |
|
35 | { |
||
36 | 47 | if (($threshold = $model->getAuditThreshold()) > 0) { |
|
37 | 1 | $forRemoval = $model->audits() |
|
38 | 1 | ->latest() |
|
39 | 1 | ->get() |
|
40 | 1 | ->slice($threshold) |
|
41 | 1 | ->pluck('id'); |
|
42 | |||
43 | 1 | if (!$forRemoval->isEmpty()) { |
|
44 | 1 | return $model->audits() |
|
45 | 1 | ->whereIn('id', $forRemoval) |
|
46 | 1 | ->delete() > 0; |
|
47 | } |
||
48 | } |
||
49 | |||
50 | 47 | return false; |
|
51 | } |
||
53 |