Passed
Push — develop ( 16ae21...f7a059 )
by Septianata
04:44
created

Attribute::getTotalAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Models\Concerns\Item;
4
5
/**
6
 * @property int $quantity_per_bundle
7
 * @property int $bundle_quantity
8
 * @property-read int $quantity
9
 * @property-read float $denomination_value
10
 * @property-read float $total
11
 *
12
 * @see \App\Models\Item
13
 */
14
trait Attribute
15
{
16
    /**
17
     * Return "quantity" attribute value.
18
     *
19
     * @return int
20
     */
21
    public function getQuantityAttribute(): int
22
    {
23
        return $this->quantity_per_bundle * $this->bundle_quantity;
24
    }
25
26
    /**
27
     * Return "denomination_value" attribute value.
28
     *
29
     * @return float
30
     */
31
    public function getDenominationValueAttribute(): float
32
    {
33
        return $this->denomination->value;
0 ignored issues
show
Bug introduced by
The property denomination does not exist on App\Models\Concerns\Item\Attribute. Did you mean denomination_value?
Loading history...
34
    }
35
36
    /**
37
     * Return "total" attribute value.
38
     *
39
     * @return float
40
     */
41
    public function getTotalAttribute(): float
42
    {
43
        return $this->quantity * $this->denomination_value;
44
    }
45
}
46