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.

PlivoChannel   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 56
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A send() 0 24 5
1
<?php
2
3
namespace NotificationChannels\Plivo;
4
5
use Illuminate\Notifications\Notification;
6
use NotificationChannels\Plivo\Exceptions\CouldNotSendNotification;
7
8
class PlivoChannel
9
{
10
    /**
11
     * @var \NotificationChannels\Plivo\Plivo;
12
     */
13
    protected $plivo;
14
15
    /**
16
     * The phone number notifications should be sent from.
17
     *
18
     * @var string
19
     */
20
    protected $from;
21
22
    /**
23
     * @return  void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
24
     */
25
    public function __construct(Plivo $plivo)
26
    {
27
        $this->plivo = $plivo;
28
        $this->from = $this->plivo->from();
29
    }
30
31
    /**
32
     * Send the given notification.
33
     *
34
     * @param mixed $notifiable
35
     * @param \Illuminate\Notifications\Notification $notification
36
     *
37
     * @throws \NotificationChannels\Plivo\Exceptions\CouldNotSendNotification
38
     */
39
    public function send($notifiable, Notification $notification)
40
    {
41
        if (! $to = $notifiable->routeNotificationFor('plivo')) {
42
            return;
43
        }
44
45
        $message = $notification->toPlivo($notifiable);
0 ignored issues
show
Bug introduced by
The method toPlivo() 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...
46
47
        if (is_string($message)) {
48
            $message = new PlivoMessage($message);
49
        }
50
51
        $response = $this->plivo->send_message([
52
            'src' => $message->from ?: $this->from,
53
            'dst' => $to,
54
            'text' => trim($message->content),
55
        ]);
56
57
        if ($response['status'] !== 202) {
58
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
59
        }
60
61
        return $response;
62
    }
63
}
64