Passed
Push — develop ( 6dcea6...5ae9a6 )
by Septianata
16:24
created

OrderStatus   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 41
ccs 0
cts 5
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canCreateSchedule() 0 3 1
A hasBeenScheduled() 0 5 2
1
<?php
2
3
namespace App\Models;
4
5
use App\Enum\OrderStatus as EnumOrderStatus;
6
use App\Infrastructure\Database\Eloquent\Model;
7
use App\Models\Contracts\MorphToIssuerable;
8
use Illuminate\Database\Eloquent\Factories\HasFactory;
9
10
class OrderStatus extends Model implements MorphToIssuerable
11
{
12
    use HasFactory,
13
        Concerns\OrderStatus\Attribute,
14
        Concerns\OrderStatus\Relation;
15
16
    /**
17
     * {@inheritDoc}
18
     */
19
    protected $fillable = [
20
        'status',
21
        'note',
22
    ];
23
24
    /**
25
     * {@inheritDoc}
26
     */
27
    protected $casts = [
28
        'status' => EnumOrderStatus::class,
29
    ];
30
31
    /**
32
     * Determine whether the current status is able to create order schedule.
33
     *
34
     * @return bool
35
     */
36
    public function canCreateSchedule(): bool
37
    {
38
        return EnumOrderStatus::on_progress()->equals($this->status);
39
    }
40
41
    /**
42
     * Determine whether the order has been scheduled.
43
     *
44
     * @return bool
45
     */
46
    public function hasBeenScheduled(): bool
47
    {
48
        return
49
            EnumOrderStatus::scheduled()->equals($this->status) ||
50
            EnumOrderStatus::rescheduled()->equals($this->status);
51
    }
52
}
53