BaseNotification::shouldSend()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace Spatie\ServerMonitor\Notifications;
4
5
use Illuminate\Notifications\Notification;
6
use Spatie\ServerMonitor\Models\Check;
7
8
abstract class BaseNotification extends Notification
9
{
10
    /**
11
     * Get the notification's delivery channels.
12
     *
13
     * @param  mixed $notifiable
14
     * @return array
15
     */
16
    public function via($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
        return config('server-monitor.notifications.notifications.'.static::class);
19
    }
20
21
    public function getCheck(): Check
22
    {
23
        return $this->event->check;
0 ignored issues
show
Bug introduced by
The property event does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24
    }
25
26
    protected function getMessageText(): ?string
27
    {
28
        return ucfirst($this->getCheck()->last_run_message);
29
    }
30
31
    protected function getSubject(): string
32
    {
33
        return "{$this->getCheck()->type} on {$this->getCheck()->host->name}";
34
    }
35
36
    abstract public function shouldSend(): bool;
37
}
38