Completed
Push — master ( baaf26...a90bcf )
by Hilmi Erdem
01:32
created

JetSmsChannel::send()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.072

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 18
ccs 8
cts 10
cp 0.8
rs 9.4285
cc 3
eloc 9
nc 3
nop 2
crap 3.072
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 2
    public function send($notifiable, Notification $notification)
23
    {
24 2
        $message = $notification->toJetSms($notifiable);
25
26 2
        if ($message instanceof ShortMessage) {
27
            JetSms::sendShortMessage($message);
0 ignored issues
show
Documentation introduced by
$message is of type object<Erdemkeren\JetSms\ShortMessage>, but the function expects a array|string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
28
29
            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