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 ( 504e43...ae690b )
by Mohamed
10:06 queued 54s
created

PusherChannel::send()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3.054

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 15
ccs 9
cts 11
cp 0.8182
rs 9.4285
cc 3
eloc 9
nc 4
nop 2
crap 3.054
1
<?php
2
3
namespace NotificationChannels\PusherPushNotifications;
4
5
use Illuminate\Notifications\Events\NotificationFailed;
6
use Illuminate\Notifications\Notification;
7
use Pusher;
8
9
class PusherChannel
10
{
11
    /** @var Pusher */
12
    protected $pusher;
13
14
    /**
15
     * @param \Pusher $pusher
16
     */
17 1
    public function __construct(Pusher $pusher)
18
    {
19 1
        $this->pusher = $pusher;
20 1
    }
21
22
    /**
23
     * Send the given notification.
24
     *
25
     * @param mixed $notifiable
26
     * @param \Illuminate\Notifications\Notification $notification
27
     *
28
     * @return void
29
     * @throws \NotificationChannels\PusherPushNotifications\Exceptions\CouldNotSendNotification
30
     */
31 1
    public function send($notifiable, Notification $notification)
32
    {
33 1
        $interest = $notifiable->routeNotificationFor('PusherPushNotifications')
34 1
            ?: $this->interestName($notifiable);
35
36 1
        $response = $this->pusher->notify(
37 1
            $interest,
38 1
            $notification->toPushNotification($notifiable)->toArray(),
39
            true
40 1
        );
41
42 1
        if (! in_array($response['status'], [200, 202])) {
43
            event(new NotificationFailed($notifiable, $notification, $response));
0 ignored issues
show
Documentation introduced by
$response is of type boolean|array<string,*,{"status":"*","body":"*"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
44
        }
45 1
    }
46
47
    /**
48
     * Get the interest name for the notifiable.
49
     *
50
     * @param $notifiable
51
     *
52
     * @return string
53
     */
54
    protected function interestName($notifiable)
55
    {
56
        $class = str_replace('\\', '.', get_class($notifiable));
57
58
        return $class.'.'.$notifiable->getKey();
59
    }
60
}
61