Conditions | 6 |
Paths | 6 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
34 | 7 | public function send(Notification $notification, Recipient $recipient): void |
|
35 | { |
||
36 | 7 | if (!$notification instanceof SmsNotification) { |
|
37 | 1 | return; |
|
38 | } |
||
39 | |||
40 | 6 | if (null === ($recipientPhoneNumber = $recipient->getRecipientContact(self::NAME, $notification))) { |
|
41 | 1 | return; |
|
42 | } |
||
43 | |||
44 | 5 | $message = $notification->toSmsMessage($recipient); |
|
45 | 5 | $message->to($recipientPhoneNumber); |
|
46 | |||
47 | 5 | if (null === $message->getFrom() && null !== $this->defaultSenderPhoneNumber) { |
|
48 | 3 | $message->from($this->defaultSenderPhoneNumber); |
|
49 | } |
||
50 | |||
51 | try { |
||
52 | 5 | $this->texter->send($message); |
|
53 | 1 | } catch (SendingMessageFailed $error) { |
|
54 | 1 | throw SendingNotificationFailed::for(self::NAME, $notification, $recipient, $error); |
|
55 | } |
||
56 | 4 | } |
|
57 | } |
||
58 |