Passed
Push — develop ( b4818b...dcecff )
by Septianata
16:14
created

OrderStatus   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 63.64%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 24
c 1
b 0
f 0
dl 0
loc 49
ccs 7
cts 11
cp 0.6364
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A labels() 0 9 1
A getIcon() 0 10 1
A getColor() 0 10 1
1
<?php
2
3
namespace App\Enum;
4
5
use Spatie\Enum\Laravel\Enum;
6
7
/**
8
 * @method static self draft()
9
 * @method static self on_progress()
10
 * @method static self scheduled()
11
 * @method static self rescheduled()
12
 * @method static self canceled()
13
 * @method static self finished()
14
 */
15
class OrderStatus extends Enum
16
{
17
    /**
18
     * {@inheritDoc}
19
     */
20 1
    protected static function labels(): array
21
    {
22
        return [
23 1
            'draft' => trans('order-status.draft'),
24 1
            'on_progress' => trans('order-status.on_progress'),
25 1
            'scheduled' => trans('order-status.scheduled'),
26 1
            'rescheduled' => trans('order-status.rescheduled'),
27 1
            'canceled' => trans('order-status.canceled'),
28 1
            'finished' => trans('order-status.finished'),
29
        ];
30
    }
31
32
    /**
33
     * Return fontawesome icon based on the enum value.
34
     *
35
     * @return string
36
     */
37
    public function getIcon(): string
38
    {
39
        return [
40
            'draft' => 'fa-calendar',
41
            'on_progress' => 'fa-calendar-alt',
42
            'scheduled' => 'fa-calendar-plus',
43
            'rescheduled' => 'fa-calendar-week',
44
            'canceled' => 'fa-calendar-times',
45
            'finished' => 'fa-calendar-check',
46
        ][$this->value];
47
    }
48
49
    /**
50
     * Return bootstrap color based on the enum value.
51
     *
52
     * @return string
53
     */
54
    public function getColor(): string
55
    {
56
        return [
57
            'draft' => 'primary',
58
            'on_progress' => 'primary',
59
            'scheduled' => 'success',
60
            'rescheduled' => 'warning',
61
            'canceled' => 'danger',
62
            'finished' => 'success',
63
        ][$this->value];
64
    }
65
}
66