Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
29 / 29 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| VisitStatus | |
100.00% |
29 / 29 |
|
100.00% |
6 / 6 |
23 | |
100.00% |
1 / 1 |
| label | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
8 | |||
| isTerminal | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| canReschedule | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| canCancel | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| canCheckIn | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| canRecordOutcome | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Visits\Domain\Enums; |
| 6 | |
| 7 | enum VisitStatus: string |
| 8 | { |
| 9 | case Requested = 'requested'; |
| 10 | case Scheduled = 'scheduled'; |
| 11 | case Confirmed = 'confirmed'; |
| 12 | case InProgress = 'in_progress'; |
| 13 | case Completed = 'completed'; |
| 14 | case Cancelled = 'cancelled'; |
| 15 | case NoShow = 'no_show'; |
| 16 | |
| 17 | public function label(): string |
| 18 | { |
| 19 | return match ($this) { |
| 20 | self::Requested => 'Solicitada', |
| 21 | self::Scheduled => 'Agendada', |
| 22 | self::Confirmed => 'Confirmada', |
| 23 | self::InProgress => 'Em andamento', |
| 24 | self::Completed => 'Realizada', |
| 25 | self::Cancelled => 'Cancelada', |
| 26 | self::NoShow => 'Não compareceu', |
| 27 | }; |
| 28 | } |
| 29 | |
| 30 | public function isTerminal(): bool |
| 31 | { |
| 32 | return match ($this) { |
| 33 | self::Completed, self::Cancelled, self::NoShow => true, |
| 34 | default => false, |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | public function canReschedule(): bool |
| 39 | { |
| 40 | return match ($this) { |
| 41 | self::Requested, self::Scheduled, self::Confirmed => true, |
| 42 | default => false, |
| 43 | }; |
| 44 | } |
| 45 | |
| 46 | public function canCancel(): bool |
| 47 | { |
| 48 | return match ($this) { |
| 49 | self::Completed, self::Cancelled, self::NoShow => false, |
| 50 | default => true, |
| 51 | }; |
| 52 | } |
| 53 | |
| 54 | public function canCheckIn(): bool |
| 55 | { |
| 56 | return match ($this) { |
| 57 | self::Scheduled, self::Confirmed => true, |
| 58 | default => false, |
| 59 | }; |
| 60 | } |
| 61 | |
| 62 | public function canRecordOutcome(): bool |
| 63 | { |
| 64 | return match ($this) { |
| 65 | self::InProgress, self::Completed => true, |
| 66 | default => false, |
| 67 | }; |
| 68 | } |
| 69 | } |