| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function send($notifiable, Notification $notification) |
||
| 31 | { |
||
| 32 | $to = $notifiable->routeNotificationFor('unisender'); |
||
| 33 | |||
| 34 | if (!$to) { |
||
| 35 | throw new \InvalidArgumentException('No receivers.'); |
||
| 36 | } |
||
| 37 | |||
| 38 | if (!method_exists($notification, 'toUnisender')) { |
||
| 39 | throw new \InvalidArgumentException('Method "toUnisender" does not exists on given notification instance.'); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** @var UnisenderMessage $message */ |
||
| 43 | $message = call_user_func_array([$notification, 'toUnisender'], [$notifiable]); |
||
| 44 | |||
| 45 | if (!($message instanceof UnisenderMessage)) { |
||
|
|
|||
| 46 | throw new \InvalidArgumentException('Message is not an instance of UnisenderMessage.'); |
||
| 47 | } |
||
| 48 | |||
| 49 | $message->to($to); |
||
| 50 | |||
| 51 | return $this->sendMessage($message); |
||
| 52 | } |
||
| 71 |