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 ( ca8eea...286f9f )
by Mohamed
08:01 queued 02:56
created

PusherChannel::send()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 17
ccs 13
cts 13
cp 1
rs 9.4285
cc 3
eloc 10
nc 4
nop 2
crap 3
1
<?php
2
3
namespace NotificationChannels\PusherPushNotifications;
4
5
use Pusher;
6
use Illuminate\Events\Dispatcher;
7
use Illuminate\Notifications\Notification;
8
use Illuminate\Notifications\Events\NotificationFailed;
9
10
class PusherChannel
11
{
12
    /**
13
     * @var \Pusher
14
     */
15
    protected $pusher;
16
17
    /**
18
     * @var \Illuminate\Events\Dispatcher
19
     */
20
    private $events;
21
22
    /**
23
     * @param \Pusher $pusher
24
     */
25 2
    public function __construct(Pusher $pusher, Dispatcher $events)
26
    {
27 2
        $this->pusher = $pusher;
28 2
        $this->events = $events;
29 2
    }
30
31
    /**
32
     * Send the given notification.
33
     *
34
     * @param mixed $notifiable
35
     * @param \Illuminate\Notifications\Notification $notification
36
     *
37
     * @return void
38
     */
39 2
    public function send($notifiable, Notification $notification)
40
    {
41 2
        $interest = $notifiable->routeNotificationFor('PusherPushNotifications')
42 2
            ?: $this->interestName($notifiable);
43
44 2
        $response = $this->pusher->notify(
45 2
            $interest,
46 2
            $notification->toPushNotification($notifiable)->toArray(),
47
            true
48 2
        );
49
50 2
        if (! in_array($response['status'], [200, 202])) {
51 1
            $this->events->fire(
52 1
                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...
53 1
            );
54 1
        }
55 2
    }
56
57
    /**
58
     * Get the interest name for the notifiable.
59
     *
60
     * @param $notifiable
61
     *
62
     * @return string
63
     */
64
    protected function interestName($notifiable)
65
    {
66
        $class = str_replace('\\', '.', get_class($notifiable));
67
68
        return $class.'.'.$notifiable->getKey();
69
    }
70
}
71