Completed
Push — master ( 99eb6b...f9962c )
by Mohamed
02:33
created

PushoverChannel::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 21
rs 9.3142
cc 2
eloc 15
nc 2
nop 2
1
<?php
2
3
namespace NotificationChannels\Pushover;
4
5
use Illuminate\Notifications\Notification;
6
7
class PushoverChannel
8
{
9
    /** @var Pushover */
10
    protected $pushover;
11
12
    /**
13
     * Create a new Pushover channel instance.
14
     *
15
     * @param  Pushover $pushover
16
     */
17
    public function __construct(Pushover $pushover)
18
    {
19
        $this->pushover = $pushover;
20
    }
21
22
    /**
23
     * Send the given notification.
24
     *
25
     * @param mixed $notifiable
26
     * @param \Illuminate\Notifications\Notification $notification
27
     *
28
     * @throws \NotificationChannels\Pushover\Exceptions\CouldNotSendNotification
29
     */
30
    public function send($notifiable, Notification $notification)
31
    {
32
        if (! $pushoverKey = $notifiable->routeNotificationFor('pushover')) {
33
            return;
34
        }
35
36
        $message = $notification->toPushover($notifiable);
0 ignored issues
show
Bug introduced by
The method toPushover() 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...
37
38
        $this->pushover->send([
39
            'user' => $pushoverKey,
40
            'message' => $message->content,
41
            'title' => $message->title,
42
            'timestamp' => $message->timestamp,
43
            'priority' => $message->priority,
44
            'url' => $message->url,
45
            'url_title' => $message->urlTitle,
46
            'sound' => $message->sound,
47
            'retry' => $message->retry,
48
            'expire' => $message->expire,
49
        ]);
50
    }
51
}
52