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

OrderStatus::getIcon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 10
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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