Lines
100.00%
7 / 7
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| HarnessError | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 7 | 100.00% | 1 / 1 | |||
| messageTemplate | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 7 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Testing\Exception; | |
| 6 | ||
| 7 | use Stewart\Contracts\Exception\ExceptionReason; | |
| 8 | ||
| 9 | enum HarnessError: string implements ExceptionReason | |
| 10 | { | |
| 11 | case AlreadyStarted = 'harness_already_started'; | |
| 12 | case AutomationMissing = 'harness_automation_missing'; | |
| 13 | case NotStarted = 'harness_not_started'; | |
| 14 | case OptionMissing = 'harness_option_missing'; | |
| 15 | case OptionUnknown = 'harness_option_unknown'; | |
| 16 | case ParameterUnresolvable = 'harness_parameter_unresolvable'; | |
| 17 | ||
| 18 | public function messageTemplate(): string | |
| 19 | { | |
| 20 | return match ($this) { | |
| 21 | self::AlreadyStarted => 'The harness already runs {class}; use one harness per app.', | |
| 22 | self::AutomationMissing => '{class} has no #[Automation] attribute, so it is not an app.', | |
| 23 | self::NotStarted => 'No app is running; call startApp() first.', | |
| 24 | self::OptionMissing => '{class}::__construct() needs option "{option}"; pass it to startApp().', | |
| 25 | self::OptionUnknown => 'Option "{option}" matches no parameter of {class}::__construct().', | |
| 26 | self::ParameterUnresolvable => '{class}::__construct() takes ${parameter} as {type}, which the harness has no fake for; pass one with provideService().', | |
| 27 | }; | |
| 28 | } | |
| 29 | } |