Lines 100.00% 10 / 10
Methods 100.00% 1 / 1
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 messageTemplate 100.00% 10 / 10 100.00% 1 / 1 10
9enum HarnessError: string implements ExceptionReason
10{
11    case AlreadyStarted = 'harness_already_started';
12    case AutomationMissing = 'harness_automation_missing';
13    case TemplateNeedsAppId = 'harness_template_needs_app_id';
14    case NotStarted = 'harness_not_started';
15    case OptionMissing = 'harness_option_missing';
16    case OptionUnknown = 'harness_option_unknown';
17    case OptionAmbiguous = 'harness_option_ambiguous';
18    case OptionRepeated = 'harness_option_repeated';
19    case ParameterUnresolvable = 'harness_parameter_unresolvable';
20
21    public function messageTemplate(): string
22    {
23        return match ($this) {
24            self::AlreadyStarted => 'The harness already runs {class}; use one harness per app.',
25            self::AutomationMissing => '{class} has neither #[Automation] nor #[AppTemplate], so it is not an app.',
26            self::TemplateNeedsAppId => '{class} is an #[AppTemplate]; pass the ID of the instance to test as startApp(appId: \'…\').',
27            self::NotStarted => 'No app is running; call startApp() first.',
28            self::OptionMissing => '{class}::__construct() needs option "{option}"; pass it to startApp().',
29            self::OptionUnknown => 'Option "{option}" matches no parameter of {class}::__construct().',
30            self::OptionAmbiguous => 'Option "{option}" matches parameters {parameters} of {class}::__construct(); use the exact name.',
31            self::OptionRepeated => '{class}::__construct() gets ${parameter} twice, as options "{firstOption}" and "{secondOption}".',
32            self::ParameterUnresolvable => '{class}::__construct() takes ${parameter} as {type}, which the harness has no fake for; pass one with provideService().',
33        };
34    }
35}