Completed
Push — master ( 8335a5...efe633 )
by Hilmi Erdem
01:29
created

JetSmsChannel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 0
cbo 2
dl 0
loc 29
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A send() 0 18 3
1
<?php
2
3
namespace NotificationChannels\JetSms;
4
5
use Erdemkeren\JetSms\ShortMessage;
6
use Illuminate\Notifications\Notification;
7
use NotificationChannels\JetSms\Exceptions\CouldNotSendNotification;
8
9
/**
10
 * Class JetSmsChannel.
11
 */
12
final class JetSmsChannel
13
{
14
    /**
15
     * Send the given notification.
16
     *
17
     * @param  mixed                                  $notifiable
18
     * @param  \Illuminate\Notifications\Notification $notification
19
     * @throws \NotificationChannels\JetSms\Exceptions\CouldNotSendNotification
20
     * @return void
21
     */
22 3
    public function send($notifiable, Notification $notification)
23
    {
24 3
        $message = $notification->toJetSms($notifiable);
25
26 3
        if ($message instanceof ShortMessage) {
27 1
            JetSms::sendShortMessage($message);
28
29 1
            return;
30
        }
31
32 2
        $to = $notifiable->routeNotificationFor('JetSms');
33
34 2
        if (empty($to)) {
35 1
            throw CouldNotSendNotification::missingRecipient();
36
        }
37
38 1
        JetSms::sendShortMessage($to, $message);
39 1
    }
40
}
41