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 ( cd2e1a...631600 )
by TJ
01:38
created

Notifications/UptimeCheckRecovered.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Spatie\UptimeMonitor\Notifications\Notifications;
4
5
use Carbon\Carbon;
6
use Illuminate\Notifications\Messages\MailMessage;
7
use Illuminate\Notifications\Messages\SlackMessage;
8
use Spatie\UptimeMonitor\Models\Enums\UptimeStatus;
9
use Illuminate\Notifications\Messages\SlackAttachment;
10
use Spatie\UptimeMonitor\Notifications\BaseNotification;
11
use Spatie\UptimeMonitor\Events\UptimeCheckRecovered as MonitorRecoveredEvent;
12
13
class UptimeCheckRecovered extends BaseNotification
14
{
15
    /** @var \Spatie\UptimeMonitor\Events\UptimeCheckRecovered */
16
    public $event;
17
18
    /**
19
     * Get the mail representation of the notification.
20
     *
21
     * @param  mixed $notifiable
22
     * @return \Illuminate\Notifications\Messages\MailMessage
23
     */
24 View Code Duplication
    public function toMail($notifiable)
25
    {
26
        $mailMessage = (new MailMessage)
27
            ->success()
28
            ->subject($this->getMessageText())
29
            ->line($this->getMessageText())
30
            ->line($this->getLocationDescription());
31
32
        foreach ($this->getMonitorProperties() as $name => $value) {
33
            $mailMessage->line($name.': '.$value);
34
        }
35
36
        return $mailMessage;
37
    }
38
39 View Code Duplication
    public function toSlack($notifiable)
40
    {
41
        return (new SlackMessage)
42
            ->success()
43
            ->attachment(function (SlackAttachment $attachment) {
44
                $attachment
45
                    ->title($this->getMessageText())
46
                    ->fallback($this->getMessageText())
47
                    ->footer($this->getLocationDescription())
48
                    ->timestamp(Carbon::now());
0 ignored issues
show
It seems like \Carbon\Carbon::now() targeting Carbon\Traits\Creator::now() can also be of type object<Carbon\Traits\Creator>; however, Illuminate\Notifications...Attachment::timestamp() does only seem to accept object<DateTimeInterface...t<DateInterval>|integer, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
49
            });
50
    }
51
52
    public function getMonitorProperties($extraProperties = []): array
53
    {
54
        $extraProperties = [
55
            "Downtime: {$this->event->downtimePeriod->duration()}" => $this->event->downtimePeriod->toText(),
56
        ];
57
58
        return parent::getMonitorProperties($extraProperties);
59
    }
60
61
    public function isStillRelevant(): bool
62
    {
63
        return $this->getMonitor()->uptime_status == UptimeStatus::UP;
64
    }
65
66
    public function setEvent(MonitorRecoveredEvent $event)
67
    {
68
        $this->event = $event;
69
70
        return $this;
71
    }
72
73
    public function getMessageText(): string
74
    {
75
        return "{$this->getMonitor()->url} has recovered after {$this->event->downtimePeriod->duration()}";
76
    }
77
}
78