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 (#42)
by
unknown
02:02
created

PusherChannel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 82.35%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 60
ccs 14
cts 17
cp 0.8235
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A interestName() 0 6 1
A __construct() 0 5 1
A send() 0 16 4
1
<?php
2
3
namespace NotificationChannels\PusherPushNotifications;
4
5
use Illuminate\Events\Dispatcher;
6
use Illuminate\Notifications\Events\NotificationFailed;
7
use Illuminate\Notifications\Notification;
8
use Pusher\PushNotifications\PushNotifications;
9
use Throwable;
10
11
class PusherChannel
12
{
13
    /**
14
     * @var PushNotifications
15
     */
16
    protected $beamsClient;
17
18
    /**
19
     * @var \Illuminate\Events\Dispatcher
20
     */
21
    private $events;
22
23
    /**
24
     * @param Pusher $pusher
0 ignored issues
show
Bug introduced by
There is no parameter named $pusher. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
25
     */
26 2
    public function __construct(PushNotifications $beamsClient, Dispatcher $events)
27
    {
28 2
        $this->beamsClient = $beamsClient;
29 2
        $this->events = $events;
30 2
    }
31
32
    /**
33
     * Send the given notification.
34
     *
35
     * @param mixed $notifiable
36
     * @param \Illuminate\Notifications\Notification $notification
37
     *
38
     * @return void
39
     */
40 2
    public function send($notifiable, Notification $notification)
41
    {
42 2
        $interest = $notifiable->routeNotificationFor('PusherPushNotifications')
43 2
            ?: $this->interestName($notifiable);
44
45
        try {
46 2
            $this->beamsClient->publishToInterests(
47 2
                is_array($interest) ? $interest : [$interest],
48 2
                $notification->toPushNotification($notifiable)->toArray()
0 ignored issues
show
Bug introduced by
The method toPushNotification() 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...
49
            );
50 1
        } catch (Throwable $exception) {
51 1
            $this->events->dispatch(
52 1
                new NotificationFailed($notifiable, $notification, 'pusher-push-notifications')
53
            );
54
        }
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