| Total Complexity | 9 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class JobStatus |
||
| 10 | { |
||
| 11 | /** @psalm-suppress MissingClassConstType */ |
||
| 12 | final public const WAITING = 1; |
||
| 13 | /** @psalm-suppress MissingClassConstType */ |
||
| 14 | final public const RESERVED = 2; |
||
| 15 | /** @psalm-suppress MissingClassConstType */ |
||
| 16 | final public const DONE = 3; |
||
| 17 | |||
| 18 | protected int $status; |
||
| 19 | |||
| 20 | 9 | final protected function __construct(int $status) |
|
| 21 | { |
||
| 22 | 9 | if (!in_array($status, $this->available(), true)) { |
|
| 23 | 1 | throw new InvalidStatusException($status); |
|
| 24 | } |
||
| 25 | |||
| 26 | 8 | $this->status = $status; |
|
| 27 | } |
||
| 28 | |||
| 29 | 9 | protected function available(): array |
|
| 32 | } |
||
| 33 | |||
| 34 | 3 | public static function waiting(): self |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | public static function reserved(): self |
|
| 40 | { |
||
| 41 | 1 | return new static(self::RESERVED); |
|
| 42 | } |
||
| 43 | |||
| 44 | 4 | public static function done(): self |
|
| 45 | { |
||
| 46 | 4 | return new static(self::DONE); |
|
| 47 | } |
||
| 48 | |||
| 49 | 4 | public function isWaiting(): bool |
|
| 50 | { |
||
| 51 | 4 | return $this->status === self::WAITING; |
|
| 52 | } |
||
| 53 | |||
| 54 | 3 | public function isReserved(): bool |
|
| 55 | { |
||
| 56 | 3 | return $this->status === self::RESERVED; |
|
| 57 | } |
||
| 58 | |||
| 59 | 5 | public function isDone(): bool |
|
| 62 | } |
||
| 63 | } |
||
| 64 |