Lines 0.00% 0 / 9
Functions and Methods 0.00% 0 / 1
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
TriggerError 0.00% 0 / 9 0.00% 0 / 1 90 0.00% 0 / 1
 messageTemplate 0.00% 0 / 9 0.00% 0 / 1 90
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Contracts\Exception;
6
7enum TriggerError: string implements ExceptionReason
8{
9    case ConfigInvalid = 'config_invalid';
10    case ConfigUnencodable = 'config_unencodable';
11    case ListEmpty = 'list_empty';
12    case TimeInvalid = 'time_invalid';
13    case TimePatternEmpty = 'time_pattern_empty';
14    case TemplateEmpty = 'template_empty';
15    case ZoneInvalid = 'zone_invalid';
16    case VariablesNotMap = 'variables_not_map';
17
18    public function messageTemplate(): string
19    {
20        return match ($this) {
21            self::ConfigInvalid => 'A Home Assistant trigger must be a map with a non-empty "trigger" or "platform" key.',
22            self::ConfigUnencodable => 'Trigger value at {path} cannot be encoded as JSON.',
23            self::ListEmpty => 'A trigger subscription needs at least one trigger.',
24            self::TimeInvalid => 'Trigger time "{time}" is neither HH:MM[:SS] nor an input_datetime or sensor entity.',
25            self::TimePatternEmpty => 'A time pattern trigger needs hours, minutes or seconds.',
26            self::TemplateEmpty => 'A template trigger needs a non-empty template.',
27            self::ZoneInvalid => 'Trigger zone "{zone}" is not a zone entity.',
28            self::VariablesNotMap => 'Trigger variables must be a map keyed by variable name.',
29        };
30    }
31}