GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 150d64...174ec2 )
by Freek
07:55
created

UptimeCheckFailed::toMail()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
1
<?php
2
3
namespace Spatie\UptimeMonitor\Notifications\Notifications;
4
5
use Illuminate\Notifications\Messages\MailMessage;
6
use Illuminate\Notifications\Messages\SlackAttachment;
7
use Illuminate\Notifications\Messages\SlackMessage;
8
use Spatie\UptimeMonitor\Events\UptimeCheckFailed as MonitorFailedEvent;
9
use Spatie\UptimeMonitor\Models\Enums\UptimeStatus;
10
use Spatie\UptimeMonitor\Notifications\BaseNotification;
11
12
class UptimeCheckFailed extends BaseNotification
13
{
14
    /** @var \Spatie\UptimeMonitor\Events\UptimeCheckFailed */
15
    public $event;
16
17
    /**
18
     * Get the mail representation of the notification.
19
     *
20
     * @param mixed $notifiable
21
     * @return \Illuminate\Notifications\Messages\MailMessage
22
     */
23
    public function toMail($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...
24
    {
25
        $mailMessage = (new MailMessage)
26
            ->error()
27
            ->subject($this->getMessageText())
28
            ->line($this->getMessageText());
29
30
        foreach ($this->getMonitorProperties() as $name => $value) {
31
            $mailMessage->line($name.': '.$value);
32
        }
33
34
        return $mailMessage;
35
    }
36
37
    public function toSlack($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...
38
    {
39
        return (new SlackMessage)
40
            ->error()
41
            ->content($this->getMessageText())
42
            ->attachment(function (SlackAttachment $attachment) {
43
                $attachment->fields($this->getMonitorProperties());
44
            });
45
    }
46
47
    public function getMonitorProperties($extraProperties = []): array
48
    {
49
        $extraProperties = [
50
            'Failing since' => $this->event->monitor->formattedLastUpdatedStatusChangeDate,
51
        ];
52
53
        return parent::getMonitorProperties($extraProperties);
54
    }
55
56
    public function isStillRelevant(): bool
57
    {
58
        return $this->event->monitor->uptime_status == UptimeStatus::DOWN;
59
    }
60
61
    public function setEvent(MonitorFailedEvent $event)
62
    {
63
        $this->event = $event;
64
65
        return $this;
66
    }
67
68
    protected function getMessageText(): string
69
    {
70
        return "{$this->event->monitor->url} seem down{$this->getLocationDescription()}.";
71
    }
72
}
73