Issues (10)

src/TextlocalChannel.php (1 issue)

1
<?php
2
3
namespace NotificationChannels\Textlocal;
4
5
use Illuminate\Notifications\Notification;
6
7
class TextlocalChannel
8
{
9
    public function __construct(TextlocalClient $client)
10
    {
11
        $this->textlocal = $client;
0 ignored issues
show
Bug Best Practice introduced by
The property textlocal does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
12
    }
13
14
    /**
15
     * Send the given notification.
16
     *
17
     * @param mixed $notifiable
18
     * @param \Illuminate\Notifications\Notification $notification
19
     *
20
     * @throws \NotificationChannels\Textlocal\Exceptions\CouldNotSendNotification
21
     */
22
    public function send($notifiable, Notification $notification)
23
    {
24
        if (! $to = $notifiable->routeNotificationFor('textlocal')) {
25
            return;
26
        }
27
28
        $message = $notification->toTextlocal($notifiable);
29
30
        if (is_string($message)) {
31
            $message = new TextlocalMessage($message);
32
        }
33
34
        return $this->textlocal->message($to, $message);
35
    }
36
}
37