Lines
66.66%
2 / 3
Functions and Methods
66.66%
2 / 3
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| StateException | 66.66% | 2 / 3 | 66.66% | 2 / 3 | 5.93 | 0.00% | 0 / 1 | |||
| entityNotFound | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| thresholdHysteresisNegative | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| thresholdNotFinite | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Exception; | |
| 6 | ||
| 7 | use Stewart\Contracts\Entity\EntityId; | |
| 8 | ||
| 9 | /** @extends StewartException<StateError> */ | |
| 10 | final class StateException extends StewartException | |
| 11 | { | |
| 12 | public static function entityNotFound(EntityId $entityId): self | |
| 13 | { | |
| 14 | return self::createForReason(StateError::EntityNotFound, entityId: $entityId->value); | |
| 15 | } | |
| 16 | ||
| 17 | public static function thresholdHysteresisNegative(string $usage, float $hysteresis): self | |
| 18 | { | |
| 19 | return self::createForReason(StateError::ThresholdHysteresisNegative, usage: $usage, hysteresis: is_nan($hysteresis) ? 'NAN' : $hysteresis); | |
| 20 | } | |
| 21 | ||
| 22 | public static function thresholdNotFinite(string $usage, float $threshold): self | |
| 23 | { | |
| 24 | return self::createForReason(StateError::ThresholdNotFinite, usage: $usage, threshold: is_nan($threshold) ? 'NAN' : $threshold); | |
| 25 | } | |
| 26 | } |