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 ( 53cbc7...9e8794 )
by
unknown
02:05
created

OneSignalChannel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 78.56%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 40
ccs 11
cts 14
cp 0.7856
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B send() 0 21 5
1
<?php
2
3
namespace NotificationChannels\OneSignal;
4
5
use Berkayk\OneSignal\OneSignalClient;
6
use Psr\Http\Message\ResponseInterface;
7
use Illuminate\Notifications\Notification;
8
use NotificationChannels\OneSignal\Exceptions\CouldNotSendNotification;
9
10
class OneSignalChannel
11
{
12
    /** @var OneSignalClient */
13
    protected $oneSignal;
14
15 1
    public function __construct(OneSignalClient $oneSignal)
16
    {
17 1
        $this->oneSignal = $oneSignal;
18 1
    }
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 1
    public function send($notifiable, Notification $notification)
29
    {
30 1
        if (! $userIds = $notifiable->routeNotificationFor('OneSignal')) {
31
            return;
32
        }
33
34 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...
35
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
45 1
        if ($response->getStatusCode() !== 200) {
46 1
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
47
        }
48
    }
49
}
50