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.

getUptimeStatusAsEmojiAttribute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
namespace Spatie\UptimeMonitor\Models\Presenters;
4
5
use Spatie\UptimeMonitor\Models\Enums\CertificateStatus;
6
use Spatie\UptimeMonitor\Models\Enums\UptimeStatus;
7
8
trait MonitorPresenter
9
{
10
    public function getUptimeStatusAsEmojiAttribute(): string
11
    {
12
        if ($this->uptime_status === UptimeStatus::UP) {
0 ignored issues
show
Bug introduced by
The property uptime_status does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13
            return '✅';
14
        }
15
16
        if ($this->uptime_status === UptimeStatus::DOWN) {
17
            return '❌';
18
        }
19
20
        return '';
21
    }
22
23
    public function getCertificateStatusAsEmojiAttribute(): string
24
    {
25
        if ($this->certificate_status === CertificateStatus::VALID) {
0 ignored issues
show
Bug introduced by
The property certificate_status does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
            return '✅';
27
        }
28
29
        if ($this->certificate_status === CertificateStatus::INVALID) {
30
            return '❌';
31
        }
32
33
        return '';
34
    }
35
36
    public function formattedLastUpdatedStatusChangeDate(string $format = ''): string
37
    {
38
        return $this->formatDate('uptime_status_last_change_date', $format);
39
    }
40
41
    public function formattedCertificateExpirationDate(string $format = ''): string
42
    {
43
        return $this->formatDate('certificate_expiration_date', $format);
44
    }
45
46
    public function getChunkedLastFailureReasonAttribute(): string
47
    {
48
        if ($this->uptime_check_failure_reason == '') {
0 ignored issues
show
Bug introduced by
The property uptime_check_failure_reason does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
49
            return '';
50
        }
51
52
        return chunk_split($this->uptime_check_failure_reason, 30, "\n");
53
    }
54
55
    public function getChunkedLastCertificateCheckFailureReasonAttribute(): string
56
    {
57
        if ($this->certificate_check_failure_reason == '') {
0 ignored issues
show
Bug introduced by
The property certificate_check_failure_reason does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
58
            return '';
59
        }
60
61
        return chunk_split($this->certificate_check_failure_reason, 60, "\n");
62
    }
63
64
    protected function formatDate(string $attributeName, string $format = ''): string
65
    {
66
        if (! $this->$attributeName) {
67
            return '';
68
        }
69
70
        if ($format === 'forHumans') {
71
            return $this->$attributeName->diffForHumans();
72
        }
73
74
        if ($format === '') {
75
            $format = config('uptime-monitor.notifications.date_format');
76
        }
77
78
        return $this->$attributeName->format($format);
79
    }
80
}
81