Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
30 | 5 | public function send(Notification $notification, Recipient $recipient): void |
|
31 | { |
||
32 | 5 | if (!$notification instanceof EmailNotification) { |
|
33 | 1 | return; |
|
34 | } |
||
35 | |||
36 | 4 | if (null === ($recipientEmail = $recipient->getRecipientContact(self::NAME, $notification))) { |
|
37 | 1 | return; |
|
38 | } |
||
39 | |||
40 | 3 | $message = $notification->toEmailMessage($recipient); |
|
41 | 3 | $message->to($recipientEmail, $recipient->getRecipientName()); |
|
42 | |||
43 | try { |
||
44 | 3 | $this->mailer->send($message); |
|
45 | 1 | } catch (SendingMessageFailed $error) { |
|
46 | 1 | throw SendingNotificationFailed::for(self::NAME, $notification, $recipient, $error); |
|
47 | } |
||
48 | 2 | } |
|
49 | } |
||
50 |