Passed
Push — develop ( f3eb57...728d57 )
by Septianata
13:03
created

Attribute::getDenominationNameAttribute()   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 1
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 string $denomination_name
10
 * @property-read float $denomination_value
11
 * @property-read float $total
12
 *
13
 * @see \App\Models\Item
14
 */
15
trait Attribute
16
{
17
    /**
18
     * Return "quantity" attribute value.
19
     *
20
     * @return int
21
     */
22
    public function getQuantityAttribute(): int
23
    {
24
        return $this->quantity_per_bundle * $this->bundle_quantity;
25
    }
26
27
    /**
28
     * Return "denomination_name" attribute value.
29
     *
30
     * @return string
31
     */
32
    public function getDenominationNameAttribute(): string
33
    {
34
        return $this->denomination->name;
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...
35
    }
36
37
    /**
38
     * Return "denomination_value" attribute value.
39
     *
40
     * @return float
41
     */
42
    public function getDenominationValueAttribute(): float
43
    {
44
        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...
45
    }
46
47
    /**
48
     * Return "total" attribute value.
49
     *
50
     * @return float
51
     */
52
    public function getTotalAttribute(): float
53
    {
54
        return $this->quantity * $this->denomination_value;
55
    }
56
}
57