Passed
Push — develop ( 2fff64...5f0aa7 )
by Septianata
04:06
created

Event::bootEvent()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 2
cts 4
cp 0.5
rs 10
cc 2
nc 1
nop 0
crap 2.5
1
<?php
2
3
namespace App\Models\Concerns\Customer;
4
5
use App\Models\Customer;
6
use App\Support\Model\Event as ModelEvent;
7
use Illuminate\Support\Facades\Storage;
8
9
/**
10
 * @see \App\Models\Customer
11
 */
12
trait Event
13
{
14
    use ModelEvent;
15
16
    /**
17
     * Boot the trait on the model.
18
     *
19
     * @return void
20
     */
21 1
    protected static function bootEvent()
22
    {
23 1
        static::saving(function (Customer $model) {
24
            if (is_null($model->identitycard_image)) {
25
                Storage::delete(Customer::IDENTITYCARD_IMAGE_PATH . '/' . $model->getRawOriginal('identitycard_image'));
0 ignored issues
show
Bug introduced by
Are you sure $model->getRawOriginal('identitycard_image') of type array|mixed can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
                Storage::delete(Customer::IDENTITYCARD_IMAGE_PATH . '/' . /** @scrutinizer ignore-type */ $model->getRawOriginal('identitycard_image'));
Loading history...
26
            }
27 1
        });
28 1
    }
29
}
30