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 ( b85ce8...d97b27 )
by Freek
02:28
created

SslCheckFailed::setEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
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\SslCheckFailed as InvalidSslCertificateFoundEvent;
9
use Spatie\UptimeMonitor\Notifications\BaseNotification;
10
11
class SslCheckFailed extends BaseNotification
12
{
13
    /** @var \Spatie\UptimeMonitor\Events\SslCheckSucceeded */
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
            ->error()
26
            ->subject("Found an invalid certificate for {$this->event->monitor->url}.")
27
            ->line('Found an invalid certificate');
28
29
        return $mailMessage;
30
    }
31
32 View Code Duplication
    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...
Duplication introduced by
This method 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...
33
    {
34
        return (new SlackMessage)
35
            ->error()
36
            ->content("Found an invalid ssl certificate for {$this->event->monitor->url}")
37
            ->attachment(function (SlackAttachment $attachment) {
38
                $attachment->fields($this->getMonitorProperties());
39
            });
40
    }
41
42
    public function getMonitorProperties($properties = []): array
43
    {
44
        $extraProperties = ['failure reason' => $this->event->monitor->ssl_certificate_failure_reason];
45
46
        return parent::getMonitorProperties($extraProperties);
47
    }
48
49
    public function setEvent(InvalidSslCertificateFoundEvent $event)
50
    {
51
        $this->event = $event;
0 ignored issues
show
Documentation Bug introduced by
It seems like $event of type object<Spatie\UptimeMoni...\Events\SslCheckFailed> is incompatible with the declared type object<Spatie\UptimeMoni...ents\SslCheckSucceeded> of property $event.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
52
53
        return $this;
54
    }
55
}
56