Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
BookStatus
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
5 / 5
7
100.00% covered (success)
100.00%
1 / 1
 label
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 isAvailable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isBorrowed
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 canBeBorrowed
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 canBeReturned
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
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
8declare(strict_types=1);
9
10namespace AppDemo\Library\Domain;
11
12use Phexium\Domain\EnumInterface;
13use Phexium\Domain\EnumTrait;
14
15enum BookStatus: string implements EnumInterface
16{
17    use EnumTrait;
18
19    case Available = 'available';
20    case Borrowed = 'borrowed';
21
22    public function label(): string
23    {
24        return match ($this) {
25            self::Available => 'Available',
26            self::Borrowed => 'Borrowed',
27        };
28    }
29
30    public function isAvailable(): bool
31    {
32        return $this === self::Available;
33    }
34
35    public function isBorrowed(): bool
36    {
37        return $this === self::Borrowed;
38    }
39
40    public function canBeBorrowed(): bool
41    {
42        return $this === self::Available;
43    }
44
45    public function canBeReturned(): bool
46    {
47        return $this === self::Borrowed;
48    }
49}