Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| LoanStatus | |
100.00% |
7 / 7 |
|
100.00% |
4 / 4 |
6 | |
100.00% |
1 / 1 |
| label | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| isActive | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isReturned | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| canBeReturned | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace AppDemo\Loan\Domain; |
| 11 | |
| 12 | use Phexium\Domain\EnumInterface; |
| 13 | use Phexium\Domain\EnumTrait; |
| 14 | |
| 15 | enum LoanStatus: string implements EnumInterface |
| 16 | { |
| 17 | use EnumTrait; |
| 18 | |
| 19 | case Active = 'active'; |
| 20 | case Returned = 'returned'; |
| 21 | |
| 22 | public function label(): string |
| 23 | { |
| 24 | return match ($this) { |
| 25 | self::Active => 'Active', |
| 26 | self::Returned => 'Returned', |
| 27 | }; |
| 28 | } |
| 29 | |
| 30 | public function isActive(): bool |
| 31 | { |
| 32 | return $this === self::Active; |
| 33 | } |
| 34 | |
| 35 | public function isReturned(): bool |
| 36 | { |
| 37 | return $this === self::Returned; |
| 38 | } |
| 39 | |
| 40 | public function canBeReturned(): bool |
| 41 | { |
| 42 | return $this === self::Active; |
| 43 | } |
| 44 | } |