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 ( 02dcd4...48a05d )
by Mohamed
02:38
created

OneSignalChannel::send()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 3
eloc 8
nc 3
nop 2
1
<?php
2
3
namespace NotificationChannels\OneSignal;
4
5
use Berkayk\OneSignal\OneSignalClient;
6
use NotificationChannels\OneSignal\Exceptions\CouldNotSendNotification;
7
use Illuminate\Notifications\Notification;
8
use Psr\Http\Message\ResponseInterface;
9
10
class OneSignalChannel
11
{
12
    /** @var OneSignalClient */
13
    protected $oneSignal;
14
15
    public function __construct(OneSignalClient $oneSignal)
16
    {
17
        $this->oneSignal = $oneSignal;
18
    }
19
20
    /**
21
     * Send the given notification.
22
     *
23
     * @param mixed $notifiable
24
     * @param \Illuminate\Notifications\Notification $notification
25
     *
26
     * @throws \NotificationChannels\OneSignal\Exceptions\CouldNotSendNotification
27
     */
28
    public function send($notifiable, Notification $notification)
29
    {
30
        if (! $userIds = $notifiable->routeNotificationFor('OneSignal')) {
31
            return;
32
        }
33
34
        $payload = $notification->toOneSignal($notifiable)->toArray();
0 ignored issues
show
Bug introduced by
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...
35
        $payload['include_player_ids'] = collect($userIds);
36
37
        /** @var ResponseInterface $response */
38
        $response = $this->oneSignal->sendNotificationCustom($payload);
39
40
        if ($response->getStatusCode() !== 200) {
41
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
42
        }
43
    }
44
}
45