Completed
Push — master ( ace356...baaf26 )
by Hilmi Erdem
01:59
created

JetSmsChannel::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
crap 2
1
<?php
2
3
namespace NotificationChannels\JetSms;
4
5
use Illuminate\Notifications\Notification;
6
use NotificationChannels\JetSms\Exceptions\CouldNotSendNotification;
7
8
/**
9
 * Class JetSmsChannel.
10
 */
11
final class JetSmsChannel
12
{
13
    /**
14
     * Send the given notification.
15
     *
16
     * @param  mixed                                  $notifiable
17
     * @param  \Illuminate\Notifications\Notification $notification
18
     * @throws \NotificationChannels\JetSms\Exceptions\CouldNotSendNotification
19
     * @return void
20
     */
21 2
    public function send($notifiable, Notification $notification)
22
    {
23 2
        $to = $notifiable->routeNotificationFor('JetSms');
24
25 2
        if (empty($to)) {
26 1
            throw CouldNotSendNotification::missingRecipient();
27
        }
28
29 1
        $message = $notification->toJetSms($notifiable);
30
31 1
        JetSms::sendShortMessage($to, $message);
32 1
    }
33
}
34