Lines
87.50%
7 / 8
Functions and Methods
66.66%
2 / 3
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| HistoryException | 87.50% | 7 / 8 | 66.66% | 2 / 3 | 4.03 | 0.00% | 0 / 1 | |||
| rejected | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 2 | |||||
| unreachable | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| timedOut | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Exception; | |
| 6 | ||
| 7 | use Stewart\Contracts\Entity\EntityId; | |
| 8 | use Throwable; | |
| 9 | ||
| 10 | /** @extends StewartException<HistoryError> */ | |
| 11 | final class HistoryException extends StewartException | |
| 12 | { | |
| 13 | public static function rejected(EntityId $entityId, string $detail, ?string $errorCode = null, ?Throwable $previous = null): self | |
| 14 | { | |
| 15 | return self::createForReasonWithAppendedText( | |
| 16 | HistoryError::Rejected, | |
| 17 | ['entityId' => $entityId->value, 'detail' => $detail, 'errorCode' => $errorCode], | |
| 18 | $errorCode === null ? null : '(' . $errorCode . ')', | |
| 19 | $previous, | |
| 20 | ); | |
| 21 | } | |
| 22 | ||
| 23 | public static function unreachable(EntityId $entityId, string $detail, ?Throwable $previous = null): self | |
| 24 | { | |
| 25 | return self::createForReason(HistoryError::Unreachable, $previous, entityId: $entityId->value, detail: $detail); | |
| 26 | } | |
| 27 | ||
| 28 | public static function timedOut(EntityId $entityId, string $detail, ?Throwable $previous = null): self | |
| 29 | { | |
| 30 | return self::createForReason(HistoryError::TimedOut, $previous, entityId: $entityId->value, detail: $detail); | |
| 31 | } | |
| 32 | } |