Lines
100.00%
5 / 5
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| WorkerHandleState | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 8 | 100.00% | 1 / 1 | |||
| canEnter | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 8 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Lifecycle; | |
| 6 | ||
| 7 | enum WorkerHandleState | |
| 8 | { | |
| 9 | case Starting; | |
| 10 | case Ready; | |
| 11 | case Stopping; | |
| 12 | case Terminated; | |
| 13 | ||
| 14 | public function canEnter(self $next): bool | |
| 15 | { | |
| 16 | return match ($this) { | |
| 17 | self::Starting => $next === self::Ready || $next === self::Stopping || $next === self::Terminated, | |
| 18 | self::Ready => $next === self::Stopping || $next === self::Terminated, | |
| 19 | self::Stopping => $next === self::Terminated, | |
| 20 | self::Terminated => false, | |
| 21 | }; | |
| 22 | } | |
| 23 | } |