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

src/PusherChannel.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace NotificationChannels\PusherPushNotifications;
4
5
use NotificationChannels\PusherPushNotifications\Exceptions\CouldNotSendNotification;
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
    public function __construct(Pusher $pusher)
18
    {
19
        $this->pusher = $pusher;
20
    }
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
    public function send($notifiable, Notification $notification)
32
    {
33
        $interest = $notifiable->routeNotificationFor('PusherPushNotifications')
34
            ?: $this->interestName($notifiable);
35
36
        $response = $this->pusher->notify(
37
            $interest,
38
            $notification->toPushNotification($notifiable)->toArray(),
39
            true
40
        );
41
42
        if (! in_array($response['status'], [200, 202])) {
43
            throw CouldNotSendNotification::pusherRespondedWithAnError($response);
0 ignored issues
show
It seems like $response defined by $this->pusher->notify($i...able)->toArray(), true) on line 36 can also be of type boolean; however, NotificationChannels\Pus...rRespondedWithAnError() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
44
        }
45
    }
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