GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 300dfd...2ea815 )
by Jhao
03:38
created

SmscRuChannel::sendMessage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2.0054

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 8
cts 9
cp 0.8889
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 2
crap 2.0054
1
<?php
2
3
namespace NotificationChannels\SmscRu;
4
5
use Illuminate\Notifications\Notification;
6
use NotificationChannels\SmscRu\Exceptions\CouldNotSendNotification;
7
8
class SmscRuChannel
9
{
10
    /** @var \NotificationChannels\SmscRu\SmscRuApi */
11
    protected $smsc;
12
13 2
    public function __construct(SmscRuApi $smsc)
14
    {
15 2
        $this->smsc = $smsc;
16 2
    }
17
18
    /**
19
     * Send the given notification.
20
     *
21
     * @param  mixed  $notifiable
22
     * @param  \Illuminate\Notifications\Notification  $notification
23
     *
24
     * @throws  \NotificationChannels\SmscRu\Exceptions\CouldNotSendNotification
25
     */
26 2
    public function send($notifiable, Notification $notification)
27
    {
28 2
        $to = $notifiable->routeNotificationFor('smscru');
29
30 2
        if (empty($to)) {
31 1
            throw CouldNotSendNotification::missingRecipient();
32
        }
33
34 1
        $message = $notification->toSmscRu($notifiable);
35
36 1
        if (is_string($message)) {
37
            $message = new SmscRuMessage($message);
38
        }
39
40 1
        $this->sendMessage($to, $message);
41 1
    }
42
43 1
    protected function sendMessage($recipient, SmscRuMessage $message)
44
    {
45 1
        if (mb_strlen($message->content) > 800) {
46
            throw CouldNotSendNotification::contentLengthLimitExceeded();
47
        }
48
49
        $params = [
50 1
            'phones'  => $recipient,
51 1
            'mes'     => $message->content,
52 1
            'sender'  => $message->from,
53 1
        ];
54
55 1
        $this->smsc->send($params);
56 1
    }
57
}
58