Passed
Push — develop ( 9324e6...f3eb57 )
by Septianata
04:31
created

Event::bootEvent()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Models\Concerns\Item;
4
5
use App\Models\Item;
6
use App\Support\Model\Event as ModelEvent;
7
8
/**
9
 * @see \App\Models\Item
10
 */
11
trait Event
12
{
13
    use ModelEvent;
14
15
    /**
16
     * Boot the trait on the model.
17
     *
18
     * @return void
19
     */
20 3
    protected static function bootEvent()
21
    {
22 3
        static::saving(function (Item $model) {
23 3
            if (is_null($model->quantity_per_bundle)) {
0 ignored issues
show
introduced by
The condition is_null($model->quantity_per_bundle) is always false.
Loading history...
24 3
                $model->quantity_per_bundle = $model->getDenominationRelationValue()->quantity_per_bundle;
25
            }
26 3
        });
27 3
    }
28
}
29