Lines
100.00%
5 / 5
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ServiceCallOutcome | 100.00% | 5 / 5 | 100.00% | 2 / 2 | 6 | 100.00% | 1 / 1 | |||
| failedWith | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 5 | |||||
| isFailure | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Model; | |
| 6 | ||
| 7 | use Stewart\Contracts\Exception\EventFireError; | |
| 8 | use Stewart\Contracts\Exception\ExceptionReason; | |
| 9 | use Stewart\Contracts\Exception\RegistryEditError; | |
| 10 | use Stewart\Contracts\Exception\ServiceCallError; | |
| 11 | ||
| 12 | enum ServiceCallOutcome: string | |
| 13 | { | |
| 14 | case Succeeded = 'succeeded'; | |
| 15 | case Rejected = 'rejected'; | |
| 16 | case Unreachable = 'unreachable'; | |
| 17 | case TimedOut = 'timed_out'; | |
| 18 | case Refused = 'refused'; | |
| 19 | ||
| 20 | public static function failedWith(ExceptionReason $reason): self | |
| 21 | { | |
| 22 | return match ($reason) { | |
| 23 | ServiceCallError::Unreachable, EventFireError::Unreachable, RegistryEditError::Unreachable => self::Unreachable, | |
| 24 | ServiceCallError::TimedOut, EventFireError::TimedOut, RegistryEditError::TimedOut => self::TimedOut, | |
| 25 | ServiceCallError::Overloaded, EventFireError::Overloaded, RegistryEditError::Overloaded => self::Refused, | |
| 26 | default => self::Rejected, | |
| 27 | }; | |
| 28 | } | |
| 29 | ||
| 30 | public function isFailure(): bool | |
| 31 | { | |
| 32 | return $this !== self::Succeeded; | |
| 33 | } | |
| 34 | } |