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

Event   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 14
ccs 2
cts 4
cp 0.5
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A bootEvent() 0 5 2
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