Lines 0.00% 0 / 6
Functions and Methods 0.00% 0 / 1
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
StateError 0.00% 0 / 6 0.00% 0 / 1 42 0.00% 0 / 1
 messageTemplate 0.00% 0 / 6 0.00% 0 / 1 42
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Contracts\Exception;
6
7enum StateError: string implements ExceptionReason
8{
9    case EntityNotFound = 'entity_not_found';
10    case StateChangedViaEvents = 'state_changed_via_events';
11    case ThresholdHysteresisNegative = 'threshold_hysteresis_negative';
12    case ThresholdNotFinite = 'threshold_not_finite';
13    case TransitionRuleConflict = 'transition_rule_conflict';
14
15    public function messageTemplate(): string
16    {
17        return match ($this) {
18            self::EntityNotFound => 'Entity "{entityId}" does not exist in Home Assistant.',
19            self::StateChangedViaEvents => 'The "{eventType}" event is only delivered through watchStateChanges(), not watchEvents().',
20            self::ThresholdHysteresisNegative => 'The hysteresis of {usage}() is {hysteresis}; it must be zero or more.',
21            self::ThresholdNotFinite => 'The threshold of {usage}() is {threshold}; it must be a finite number.',
22            self::TransitionRuleConflict => 'whenChangedTo() takes either from: or fromAnyState:, not both.',
23        };
24    }
25}