Issues (4)

src/PusherApiChannel.php (2 issues)

1
<?php
2
3
namespace Andreshg112\PusherApiNotifications;
4
5
use Andreshg112\PusherApiNotifications\Exceptions\CouldNotSendNotification;
6
use Illuminate\Notifications\Notification;
7
8
class PusherApiChannel
9
{
10
    /** @var \Pusher|\Pusher\Pusher */
11
    protected $pusher;
12
13 2
    public function __construct(\Pusher $pusher)
14
    {
15 2
        $this->pusher = $pusher;
16 2
    }
17
18
    /**
19
     * Send the given notification.
20
     *
21
     * @param  mixed  $notifiable
22
     * @param  \Illuminate\Notifications\Notification  $notification
23
     *
24
     * @throws \Andreshg112\PusherApiNotifications\Exceptions\CouldNotSendNotification
25
     */
26 2
    public function send($notifiable, Notification $notification)
27
    {
28
        /** @var PusherApiMessage $pusherApiMessage */
29 2
        $pusherApiMessage = $notification->toApiNotification($notifiable);
0 ignored issues
show
The method toApiNotification() does not exist on Illuminate\Notifications\Notification. It seems like you code against a sub-type of Illuminate\Notifications\Notification such as Andreshg112\PusherApiNot...s\Test\TestNotification. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        /** @scrutinizer ignore-call */ 
30
        $pusherApiMessage = $notification->toApiNotification($notifiable);
Loading history...
30
31 2
        $message = $pusherApiMessage->toArray();
32
33 2
        $response = $this->pusher::trigger(
0 ignored issues
show
Bug Best Practice introduced by
The method Pusher\Pusher::trigger() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        /** @scrutinizer ignore-call */ 
34
        $response = $this->pusher::trigger(
Loading history...
34 2
            $message['channels'],
35 2
            $message['event'],
36 2
            $message['data'],
37 2
            $message['socketId'] ?? null,
38 2
            $message['debug'] ?? false,
39 2
            $message['alreadyEncoded'] ?? false
40
        );
41
42 2
        if (! $response) {
43 1
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
44
        }
45 1
    }
46
}
47