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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 86.36%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 50
ccs 19
cts 22
cp 0.8636
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 16 3
A sendMessage() 0 14 2
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