Passed
Push — develop ( d32912...6dcea6 )
by Septianata
05:48
created

Denomination   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A isBetweenOrderBundle() 0 11 4
1
<?php
2
3
namespace App\Models;
4
5
use App\Enum\DenominationType;
6
use App\Infrastructure\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Factories\HasFactory;
8
9
class Denomination extends Model
10
{
11
    use HasFactory,
12
        Concerns\Denomination\Attribute,
13
        Concerns\Denomination\Event,
14
        Concerns\Denomination\Relation;
15
16
    /**
17
     * Filepath value for image.
18
     *
19
     * @var string
20
     */
21
    const IMAGE_PATH = 'denomination';
22
23
    /**
24
     * {@inheritDoc}
25
     */
26
    protected $fillable = [
27
        'name',
28
        'value',
29
        'type',
30
        'quantity_per_bundle',
31
        'minimum_order_bundle',
32
        'maximum_order_bundle',
33
        'image',
34
    ];
35
36
    /**
37
     * {@inheritDoc}
38
     */
39
    protected $casts = [
40
        'value' => 'float',
41
        'type' => DenominationType::class,
42
        'quantity_per_bundle' => 'integer',
43
        'minimum_order_bundle' => 'integer',
44
        'maximum_order_bundle' => 'integer',
45
    ];
46
47
    /**
48
     * Determine whether the given value is between the minimum and maximum order bundle.
49
     *
50
     * @param  int  $value
51
     * @param  bool  $equal
52
     * @return bool
53
     */
54
    public function isBetweenOrderBundle(int $value, bool $equal = true): bool
55
    {
56
        if ($equal) {
57
            return
58
                $value >= $this->minimum_order_bundle &&
59
                $value <= $this->maximum_order_bundle;
60
        }
61
62
        return
63
            $value > $this->minimum_order_bundle &&
64
            $value < $this->maximum_order_bundle;
65
    }
66
}
67