| @@ 9-38 (lines=30) @@ | ||
| 6 | use DateTime; |
|
| 7 | use Exception; |
|
| 8 | ||
| 9 | class NotificationLockedException extends Exception |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var Notification |
|
| 13 | */ |
|
| 14 | private $notification; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * @param Notification $notification |
|
| 18 | */ |
|
| 19 | public function __construct(Notification $notification) |
|
| 20 | { |
|
| 21 | $this->notification = $notification; |
|
| 22 | parent::__construct( |
|
| 23 | sprintf( |
|
| 24 | 'Cannot send locked notification: "%s" created at %s', |
|
| 25 | $this->notification->subject()->subject(), |
|
| 26 | $this->notification->createdAt()->format(DateTime::W3C) |
|
| 27 | ) |
|
| 28 | ); |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @return Notification |
|
| 33 | */ |
|
| 34 | public function notification(): Notification |
|
| 35 | { |
|
| 36 | return $this->notification; |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| @@ 10-42 (lines=33) @@ | ||
| 7 | use Exception; |
|
| 8 | use Throwable; |
|
| 9 | ||
| 10 | class NotificationNotSentException extends Exception |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var Notification |
|
| 14 | */ |
|
| 15 | private $notification; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @param Notification $notification |
|
| 19 | * @param Throwable|null $previous |
|
| 20 | */ |
|
| 21 | public function __construct(Notification $notification, Throwable $previous = null) |
|
| 22 | { |
|
| 23 | $this->notification = $notification; |
|
| 24 | parent::__construct( |
|
| 25 | sprintf( |
|
| 26 | 'Failed to send notification: "%s" created at %s', |
|
| 27 | $this->notification->subject()->subject(), |
|
| 28 | $this->notification->createdAt()->format(DateTime::W3C) |
|
| 29 | ), |
|
| 30 | 0, |
|
| 31 | $previous |
|
| 32 | ); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @return Notification |
|
| 37 | */ |
|
| 38 | public function notification(): Notification |
|
| 39 | { |
|
| 40 | return $this->notification; |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||