BaseNotification   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
shouldSend() 0 1 ?
A via() 0 4 1
A getCheck() 0 4 1
A getMessageText() 0 4 1
A getSubject() 0 4 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