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 ( 330865...b1ea0f )
by Atymic
02:03
created

PusherChannel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
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 61
ccs 14
cts 17
cp 0.8235
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A send() 0 16 4
A interestName() 0 6 1
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 PushNotifications $beamsClient
25
     * @param Dispatcher $events
26
     */
27 2
    public function __construct(PushNotifications $beamsClient, Dispatcher $events)
28
    {
29 2
        $this->beamsClient = $beamsClient;
30 2
        $this->events = $events;
31 2
    }
32
33
    /**
34
     * Send the given notification.
35
     *
36
     * @param mixed $notifiable
37
     * @param \Illuminate\Notifications\Notification $notification
38
     *
39
     * @return void
40
     */
41 2
    public function send($notifiable, Notification $notification)
42
    {
43 2
        $interest = $notifiable->routeNotificationFor('PusherPushNotifications')
44 2
            ?: $this->interestName($notifiable);
45
46
        try {
47 2
            $this->beamsClient->publishToInterests(
48 2
                is_array($interest) ? $interest : [$interest],
49 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...
50
            );
51 1
        } catch (Throwable $exception) {
52 1
            $this->events->dispatch(
53 1
                new NotificationFailed($notifiable, $notification, 'pusher-push-notifications')
54
            );
55
        }
56 2
    }
57
58
    /**
59
     * Get the interest name for the notifiable.
60
     *
61
     * @param $notifiable
62
     *
63
     * @return string
64
     */
65
    protected function interestName($notifiable)
66
    {
67
        $class = str_replace('\\', '.', get_class($notifiable));
68
69
        return $class.'.'.$notifiable->getKey();
70
    }
71
}
72