Passed
Push — develop ( dcecff...37402c )
by Septianata
16:01
created

Item::countQuantityAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Models;
4
5
use App\Infrastructure\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Factories\HasFactory;
7
8
class Item extends Model
9
{
10
    use HasFactory,
0 ignored issues
show
introduced by
The trait App\Models\Concerns\Item\Attribute requires some properties which are not provided by App\Models\Item: $name, $value
Loading history...
11
        Concerns\Item\Attribute,
12
        Concerns\Item\Event,
13
        Concerns\Item\QueryScope,
14
        Concerns\Item\Relation;
15
16
    /**
17
     * {@inheritDoc}
18
     */
19
    protected $fillable = [
20
        'quantity_per_bundle',
21
        'bundle_quantity',
22
        'quantity',
23
        'is_order_custom_quantity',
24
    ];
25
26
    /**
27
     * {@inheritDoc}
28
     */
29
    protected $casts = [
30
        'quantity_per_bundle' => 'integer',
31
        'bundle_quantity' => 'integer',
32
        'quantity' => 'integer',
33
        'is_order_custom_quantity' => 'boolean',
34
    ];
35
36
    /**
37
     * Count value of "quantity" attribute.
38
     *
39
     * @return int
40
     */
41 2
    public function countQuantityAttribute(): int
42
    {
43 2
        return $this->quantity_per_bundle * $this->bundle_quantity;
44
    }
45
}
46