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
Pull Request — master (#40)
by
unknown
02:10
created

OneSignalChannel::send()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5.5069

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 19
ccs 8
cts 11
cp 0.7272
rs 8.8571
cc 5
eloc 11
nc 5
nop 2
crap 5.5069
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
13
    /** @var OneSignalClient */
14
    protected $oneSignal;
15
16 1
    public function __construct(OneSignalClient $oneSignal)
17
    {
18 1
        $this->oneSignal = $oneSignal;
19 1
    }
20
21
    /**
22
     * Send the given notification.
23
     *
24
     * @param mixed                                  $notifiable
25
     * @param \Illuminate\Notifications\Notification $notification
26
     *
27
     * @throws \NotificationChannels\OneSignal\Exceptions\CouldNotSendNotification
28
     */
29 1
    public function send($notifiable, Notification $notification)
30
    {
31 1
        if (!$userIds = $notifiable->routeNotificationFor('OneSignal')) {
32
            return;
33
        }
34
35 1
        $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...
36 1
        if (is_array($userIds) && array_key_exists('email', $userIds)) {
37
            $payload['filters'] = collect([["field" => "email", "value" => $userIds['email']]]);
38
        } else {
39 1
            $payload['include_player_ids'] = collect($userIds);
40
        }
41
42
        /** @var ResponseInterface $response */
43 1
        $response = $this->oneSignal->sendNotificationCustom($payload);
44 1
        if ($response->getStatusCode() !== 200) {
45 1
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
46
        }
47
    }
48
}
49