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