| Conditions | 6 |
| Paths | 16 |
| Total Lines | 27 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 6.0208 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | 4 | public function send($notifiable, Notification $notification) |
|
| 30 | { |
||
| 31 | 4 | $message = $notification->toZonerSmsGateway($notifiable); |
|
| 32 | |||
| 33 | 4 | if (is_string($message)) { |
|
| 34 | $message = new ZonerSmsGatewayMessage($message); |
||
| 35 | } |
||
| 36 | |||
| 37 | // Use the receiver from message, if defined: |
||
| 38 | 4 | $receiver = $message->receiver; |
|
| 39 | |||
| 40 | // Otherwise use the receiver given by notifiable: |
||
| 41 | 4 | if (empty($receiver)) { |
|
| 42 | 3 | $receiver = $notifiable->routeNotificationFor(ZonerSmsGatewayChannel::class); |
|
| 43 | } |
||
| 44 | |||
| 45 | // As the last resort, try to get the phone_number attribute from notifiable: |
||
| 46 | 4 | if (empty($receiver) && isset($notifiable->phone_number)) { |
|
| 47 | 1 | $receiver = $notifiable->phone_number; |
|
| 48 | } |
||
| 49 | |||
| 50 | 4 | if (empty($receiver)) { |
|
| 51 | 2 | throw CouldNotSendNotification::receiverNotProvided(); |
|
| 52 | } |
||
| 53 | |||
| 54 | 2 | return $this->gateway->sendMessage($receiver, trim($message->content), $message->sender); |
|
| 55 | } |
||
| 56 | } |
||
| 57 |