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 ( 0941c5...11f95b )
by Freek
02:01
created

BackupHasFailed   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toMail() 0 16 1
A toSlack() 0 19 1
A setEvent() 0 6 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\Backup\Events\BackupHasFailed as BackupHasFailedEvent;
9
use Spatie\Backup\Notifications\BaseNotification;
10
11
class BackupHasFailed extends BaseNotification
12
{
13
    /** @var \Spatie\Backup\Events\BackupHasFailed */
14
    protected $event;
15
16
    /**
17
     * Get the mail representation of the notification.
18
     *
19
     * @param  mixed $notifiable
20
     * @return \Illuminate\Notifications\Messages\MailMessage
21
     */
22
    public function toMail($notifiable)
23
    {
24
        $mailMessage = (new MailMessage)
25
            ->error()
26
            ->subject("Failed back up of `{$this->getApplicationName()}`")
27
            ->line("Important: An error occurred while backing up `{$this->getApplicationName()}`")
28
            ->line("Exception message: `{$this->event->exception->getMessage()}`")
29
            ->line("Exception trace: `{$this->event->exception->getTraceAsString()}`");
30
31
32
        $this->getBackupDestinationProperties()->each(function ($value, $name) use ($mailMessage) {
33
            $mailMessage->line("{$name}: $value");
34
        });
35
36
        return $mailMessage;
37
    }
38
39
    public function toSlack($notifiable)
40
    {
41
        return (new SlackMessage)
42
            ->error()
43
            ->content("Failed back up of `{$this->getApplicationName()}`")
44
            ->attachment(function (SlackAttachment $attachment) {
45
                $attachment
46
                    ->title('Exception message')
47
                    ->content($this->event->exception->getMessage());
48
            })
49
            ->attachment(function (SlackAttachment $attachment) {
50
                $attachment
51
                    ->title('Exception trace')
52
                    ->content($this->event->exception->getTraceAsString());
53
            })
54
            ->attachment(function (SlackAttachment $attachment) {
55
                $attachment->fields($this->getBackupDestinationProperties()->toArray());
56
            });
57
    }
58
59
    public function setEvent(BackupHasFailedEvent $event)
60
    {
61
        $this->event = $event;
62
63
        return $this;
64
    }
65
}
66