Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
76.19% covered (warning)
76.19%
16 / 21
50.00% covered (danger)
50.00%
3 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
ProductionStatus
76.19% covered (warning)
76.19%
16 / 21
50.00% covered (danger)
50.00%
3 / 6
22.37
0.00% covered (danger)
0.00%
0 / 1
 values
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 fromStored
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 label
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 icon
71.43% covered (warning)
71.43%
5 / 7
0.00% covered (danger)
0.00%
0 / 1
6.84
 badgeClass
71.43% covered (warning)
71.43%
5 / 7
0.00% covered (danger)
0.00%
0 / 1
6.84
 isOpen
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Enums;
4
5enum ProductionStatus: string
6{
7    case Draft = 'Draft';
8    case Planned = 'Planned';
9    case InProgress = 'InProgress';
10    case Completed = 'Completed';
11    case Cancelled = 'Cancelled';
12
13    /** @return string[] */
14    public static function values(): array
15    {
16        return array_map(fn (self $c) => $c->value, self::cases());
17    }
18
19    public static function fromStored(?string $value): self
20    {
21        return self::tryFrom((string) $value) ?? self::Draft;
22    }
23
24    public function label(): string
25    {
26        return match ($this) {
27            self::InProgress => 'In Progress',
28            default => $this->value,
29        };
30    }
31
32    public function icon(): string
33    {
34        return match ($this) {
35            self::Draft => 'fa-file',
36            self::Planned => 'fa-calendar-check',
37            self::InProgress => 'fa-gears',
38            self::Completed => 'fa-check-circle',
39            self::Cancelled => 'fa-ban',
40        };
41    }
42
43    public function badgeClass(): string
44    {
45        return match ($this) {
46            self::Draft => 'bg-secondary',
47            self::Planned => 'bg-info text-dark',
48            self::InProgress => 'bg-warning text-dark',
49            self::Completed => 'bg-success',
50            self::Cancelled => 'bg-danger',
51        };
52    }
53
54    /** Only these can still be edited/completed/cancelled. */
55    public function isOpen(): bool
56    {
57        return in_array($this, [self::Draft, self::Planned, self::InProgress], true);
58    }
59}