Completed
Push — master ( 7eb56b...d33fa5 )
by Freek
13s
created

Notifiable::setEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Spatie\ServerMonitor\Notifications;
4
5
use Illuminate\Notifications\Notifiable as NotifiableTrait;
6
7
class Notifiable
8
{
9
    use NotifiableTrait;
10
11
    /** @var \Spatie\ServerMonitor\Events\Event */
12
    protected $event;
13
14
    public function routeNotificationForMail(): ?array
15
    {
16
        return $this->explodeArray(config('server-monitor.notifications.mail.to'));
17
    }
18
19
    public function routeNotificationForSlack(): ?string
20
    {
21
        return config('server-monitor.notifications.slack.webhook_url');
22
    }
23
24
    public function getKey(): string
25
    {
26
        return static::class;
27
    }
28
29
    /**
30
     * Get the event for the notification.
31
     *
32
     * @return \Spatie\ServerMonitor\Events\Event
33
     */
34
    public function getEvent(): \Spatie\ServerMonitor\Events\Event
35
    {
36
        return $this->event;
37
    }
38
39
    /**
40
     * Set the event for the notification.
41
     *
42
     * @param \Spatie\ServerMonitor\Events\Event $event
43
     *
44
     * @return Notifiable
45
     */
46
    public function setEvent(\Spatie\ServerMonitor\Events\Event $event): Notifiable
47
    {
48
        $this->event = $event;
49
50
        return $this;
51
    }
52
53
    protected function explodeArray($mails): ?array
54
    {
55
        if(!is_array($mails)) {
56
            return explode(',', $mails);
57
        }
58
        return $mails;
59
    }
60
}
61