Issues (2)

src/SmsBroadcastChannel.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace NotificationChannels\SmsBroadcast;
4
5
use Atymic\SmsBroadcast\Api\Client;
6
use Illuminate\Notifications\Notification;
7
8
class SmsBroadcastChannel
9
{
10
    /** @var Client */
11
    private $smsBroadcastClient;
12
13
    public function __construct(Client $smsBroadcastClient)
14
    {
15
        $this->smsBroadcastClient = $smsBroadcastClient;
16
    }
17
18
    public function send($notifiable, Notification $notification): void
19
    {
20
        if (! $to = $notifiable->routeNotificationFor('smsbroadcast')) {
21
            return;
22
        }
23
24
        $message = $notification->toSmsBroadcast($notifiable);
0 ignored issues
show
The method toSmsBroadcast() does not exist on Illuminate\Notifications\Notification. ( Ignorable by Annotation )

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

24
        /** @scrutinizer ignore-call */ 
25
        $message = $notification->toSmsBroadcast($notifiable);

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...
25
26
        if (is_string($message)) {
27
            $message = new SmsBroadcastMessage($message);
28
        }
29
30
        if (! $message instanceof SmsBroadcastMessage) {
31
            return;
32
        }
33
34
        try {
35
            $this->smsBroadcastClient->send(
36
                $to,
37
                $message->content,
38
                $message->sender,
39
                $message->reference,
40
                true,
41
                $message->delay
42
            );
43
        } catch (\Exception $e) {
44
            report($e);
0 ignored issues
show
The function report was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

44
            /** @scrutinizer ignore-call */ 
45
            report($e);
Loading history...
45
46
            return;
47
        }
48
    }
49
}
50