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

CertificateCheckSucceeded   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toMail() 13 13 2
A toSlack() 9 9 1
A setEvent() 6 6 1
A getMessageText() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\CertificateCheckSucceeded as ValidCertificateFoundEvent;
9
use Spatie\UptimeMonitor\Notifications\BaseNotification;
10
11 View Code Duplication
class CertificateCheckSucceeded extends BaseNotification
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /** @var \Spatie\UptimeMonitor\Events\CertificateCheckSucceeded */
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
            ->success()
26
            ->subject($this->getMessageText())
27
            ->line($this->getMessageText());
28
29
        foreach ($this->getMonitorProperties() as $name => $value) {
30
            $mailMessage->line($name.': '.$value);
31
        }
32
33
        return $mailMessage;
34
    }
35
36
    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...
37
    {
38
        return (new SlackMessage)
39
            ->success()
40
            ->content("The certificate check for {$this->event->monitor->url} succeeded.")
41
            ->attachment(function (SlackAttachment $attachment) {
42
                $attachment->fields($this->getMonitorProperties());
43
            });
44
    }
45
46
    public function setEvent(ValidCertificateFoundEvent $event)
47
    {
48
        $this->event = $event;
49
50
        return $this;
51
    }
52
53
    public function getMessageText(): string
54
    {
55
        return "{$this->event->monitor->url} has a valid certificate{$this->getLocationDescription()}.";
56
    }
57
}
58