| Conditions | 6 |
| Paths | 7 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | public function send($notifiable, Notification $notification) |
||
| 45 | { |
||
| 46 | if (! $to = $notifiable->routeNotificationFor('jusibe')) { |
||
| 47 | throw CouldNotSendNotification::missingTo(); |
||
| 48 | } |
||
| 49 | |||
| 50 | $message = $notification->toJusibe($notifiable); |
||
| 51 | |||
| 52 | if (is_string($message)) { |
||
| 53 | $message = new JusibeMessage($message); |
||
| 54 | } |
||
| 55 | |||
| 56 | if (! $from = $message->from ?: config('services.jusibe.sms_from')) { |
||
| 57 | throw CouldNotSendNotification::missingFrom(); |
||
| 58 | } |
||
| 59 | |||
| 60 | try { |
||
| 61 | $response = $this->jusibe->sendSMS([ |
||
| 62 | 'to' => $to, |
||
| 63 | 'from' => $from, |
||
| 64 | 'message' => trim($message->content) |
||
| 65 | ])->getResponse(); |
||
| 66 | |||
| 67 | return $response; |
||
| 68 | } catch(DomainException $e) { |
||
| 69 | throw CouldNotSendNotification::serviceRespondedWithAnError($exception); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | } |
||
| 74 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.