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

JetSmsChannel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%

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 8
cts 10
cp 0.8
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 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