Conditions | 4 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 6 |
Changes | 5 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
15 | 47 | public function audit(Auditable $model): Audit |
|
16 | { |
||
17 | 47 | $implementation = Config::get('audit.implementation', \OwenIt\Auditing\Models\Audit::class); |
|
18 | |||
19 | // If we want to avoid storing Audits with empty old_values & new_values, return null here. |
||
20 | 47 | if (! Config::get('audit.empty_values')) { |
|
21 | $attributeGetter = $model->resolveAttributeGetter($model->getAuditEvent()); |
||
|
|||
22 | list($old, $new) = $model->$attributeGetter(); |
||
23 | if (empty($old) && empty($new)) { |
||
24 | return null; |
||
25 | } |
||
26 | } |
||
27 | |||
28 | 47 | return call_user_func([$implementation, 'create'], $model->toAudit()); |
|
29 | } |
||
53 |