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
Pull Request — master (#33)
by Freek
02:12
created

CertificateExpiresSoon   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 0
loc 45
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toMail() 0 12 2
A toSlack() 0 8 1
A getMessageText() 0 4 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\UptimeMonitor\Events\CertificateExpiresSoon as SoonExpiringSslCertificateFoundEvent;
9
use Spatie\UptimeMonitor\Notifications\BaseNotification;
10
11
class CertificateExpiresSoon extends BaseNotification
12
{
13
    /** @var \Spatie\UptimeMonitor\Events\CertificateExpiresSoon */
14
    public $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)
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...
23
    {
24
        $mailMessage = (new MailMessage)
25
            ->subject($this->getMessageText())
26
            ->line($this->getMessageText());
27
28
        foreach ($this->getMonitorProperties() as $name => $value) {
29
            $mailMessage->line($name.': '.$value);
30
        }
31
32
        return $mailMessage;
33
    }
34
35
    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...
36
    {
37
        return (new SlackMessage)
38
            ->content($this->getMessageText())
39
            ->attachment(function (SlackAttachment $attachment) {
40
                $attachment->fields($this->getMonitorProperties());
41
            });
42
    }
43
44
    protected function getMessageText(): string
45
    {
46
        return "The certificate for {$this->event->monitor->url} will expire in {$this->event->monitor->certificate_expiration_date->diffInDays()} days.";
47
    }
48
49
    public function setEvent(SoonExpiringSslCertificateFoundEvent $event)
50
    {
51
        $this->event = $event;
52
53
        return $this;
54
    }
55
}
56