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 ( 8af44e...38ce7d )
by Atymic
05:01
created

src/PlivoChannel.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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);
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