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