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 ( 53051f...8c4fc0 )
by Jhao
01:31
created

SmscRuChannel   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A sendMessage() 0 18 3
A __construct() 0 4 1
A send() 0 16 3
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
    public function __construct(SmscRuApi $smsc)
14
    {
15
        $this->smsc = $smsc;
16
    }
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
    public function send($notifiable, Notification $notification)
27
    {
28
        $to = $notifiable->routeNotificationFor('smscru');
29
30
        if (empty($to)) {
31
            throw CouldNotSendNotification::missingRecipient();
32
        }
33
34
        $message = $notification->toSmscRu($notifiable);
0 ignored issues
show
Bug introduced by
The method toSmscRu() does not seem to exist on object<Illuminate\Notifications\Notification>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
36
        if (is_string($message)) {
37
            $message = new SmscRuMessage($message);
38
        }
39
40
        $this->sendMessage($to, $message);
41
    }
42
43
    protected function sendMessage($recipient, SmscRuMessage $message)
44
    {
45
        if (mb_strlen($message->content) > 800) {
46
            throw CouldNotSendNotification::contentLengthLimitExceeded();
47
        }
48
49
        $params = [
50
            'phones'  => $recipient,
51
            'mes'     => $message->content,
52
            'sender'  => $message->from,
53
        ];
54
55
        if ($message->sendAt instanceof \DateTimeInterface) {
56
            $params['time'] = '0'.$message->sendAt->getTimestamp();
57
        }
58
59
        $this->smsc->send($params);
60
    }
61
}
62