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 ( fab06f...7d47fd )
by Marcel
10:31
created

src/OneSignalChannel.php (1 issue)

Labels
Severity

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\OneSignal;
4
5
use Berkayk\OneSignal\OneSignalClient;
6
use NotificationChannels\OneSignal\Exceptions\CouldNotSendNotification;
7
use NotificationChannels\OneSignal\Events\MessageWasSent;
8
use NotificationChannels\OneSignal\Events\SendingMessage;
9
use Illuminate\Notifications\Notification;
10
use Psr\Http\Message\ResponseInterface;
11
12
class OneSignalChannel
13
{
14
    /** @var OneSignalClient */
15
    protected $oneSignal;
16
17
    public function __construct(OneSignalClient $oneSignal)
18
    {
19
        $this->oneSignal = $oneSignal;
20
    }
21
22
    /**
23
     * Send the given notification.
24
     *
25
     * @param mixed $notifiable
26
     * @param \Illuminate\Notifications\Notification $notification
27
     *
28
     * @throws \NotificationChannels\OneSignal\Exceptions\CouldNotSendNotification
29
     */
30
    public function send($notifiable, Notification $notification)
31
    {
32
        if (! $userIds = $notifiable->routeNotificationFor('OneSignal')) {
33
            return;
34
        }
35
36
        $shouldSendMessage = event(new SendingMessage($notifiable, $notification), [], true) !== false;
37
38
        if (! $shouldSendMessage) {
39
            return;
40
        }
41
42
        $payload = $notification->toOneSignal($notifiable)->toArray();
0 ignored issues
show
The method toOneSignal() 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...
43
        $payload['include_player_ids'] = collect($userIds);
44
45
        /** @var ResponseInterface $response */
46
        $response = $this->oneSignal->sendNotificationCustom($payload);
47
48
        if ($response->getStatusCode() !== 200) {
49
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
50
        }
51
52
        event(new MessageWasSent($notifiable, $notification));
53
    }
54
}
55