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 Illuminate\Contracts\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\Contracts\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
|
|||
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 |
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.