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

Attribute   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTotalAttribute() 0 3 1
A getDenominationNameAttribute() 0 3 1
A getQuantityAttribute() 0 3 1
A getDenominationValueAttribute() 0 3 1
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