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 (#39)
by Sebastian
02:08
created

getChunkedLastCertificateCheckFailureReasonAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Spatie\UptimeMonitor\Models\Presenters;
4
5
use Spatie\UptimeMonitor\Helpers\Emoji;
6
use Spatie\UptimeMonitor\Models\Enums\CertificateStatus;
7
use Spatie\UptimeMonitor\Models\Enums\UptimeStatus;
8
9
trait MonitorPresenter
10
{
11
    public function getUptimeStatusAsEmojiAttribute(): string
12
    {
13
        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...
14
            return Emoji::ok();
15
        }
16
17
        if ($this->uptime_status === UptimeStatus::DOWN) {
18
            return Emoji::notOk();
19
        }
20
21
        return '';
22
    }
23
24
    public function getCertificateStatusAsEmojiAttribute(): string
25
    {
26
        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...
27
            return Emoji::ok();
28
        }
29
30
        if ($this->certificate_status === CertificateStatus::INVALID) {
31
            return Emoji::notOk();
32
        }
33
34
        return '';
35
    }
36
37
    public function getFormattedLastUpdatedStatusChangeDateAttribute(): string
38
    {
39
        return $this->formatDate('uptime_status_last_change_date');
40
    }
41
42
    public function getFormattedCertificateExpirationDateAttribute(): string
43
    {
44
        return $this->formatDate('certificate_expiration_date');
45
    }
46
47
    public function getChunkedLastFailureReasonAttribute(): string
48
    {
49
        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...
50
            return '';
51
        }
52
53
        return chunk_split($this->uptime_check_failure_reason, 30, "\n");
54
    }
55
56
    public function getChunkedLastCertificateCheckFailureReasonAttribute(): string
57
    {
58
        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...
59
            return '';
60
        }
61
62
        return chunk_split($this->certificate_check_failure_reason, 60, "\n");
63
    }
64
65
    protected function formatDate(string $attributeName): string
66
    {
67
        if (! $this->$attributeName) {
68
            return '';
69
        }
70
71
        return $this->$attributeName->diffForHumans();
72
    }
73
}
74