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\Models\Presenters; |
||
4 | |||
5 | use Spatie\UptimeMonitor\Helpers\Emoji; |
||
6 | use Spatie\UptimeMonitor\Models\Enums\UptimeStatus; |
||
7 | use Spatie\UptimeMonitor\Models\Enums\CertificateStatus; |
||
8 | |||
9 | trait MonitorPresenter |
||
10 | { |
||
11 | public function getUptimeStatusAsEmojiAttribute(): string |
||
12 | { |
||
13 | if ($this->uptime_status === UptimeStatus::UP) { |
||
0 ignored issues
–
show
|
|||
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
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;
![]() |
|||
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 formattedLastUpdatedStatusChangeDate(string $format = ''): string |
||
38 | { |
||
39 | return $this->formatDate('uptime_status_last_change_date', $format); |
||
40 | } |
||
41 | |||
42 | public function formattedCertificateExpirationDate(string $format = ''): string |
||
43 | { |
||
44 | return $this->formatDate('certificate_expiration_date', $format); |
||
45 | } |
||
46 | |||
47 | public function getChunkedLastFailureReasonAttribute(): string |
||
48 | { |
||
49 | if ($this->uptime_check_failure_reason == '') { |
||
0 ignored issues
–
show
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;
![]() |
|||
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
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;
![]() |
|||
59 | return ''; |
||
60 | } |
||
61 | |||
62 | return chunk_split($this->certificate_check_failure_reason, 60, "\n"); |
||
63 | } |
||
64 | |||
65 | protected function formatDate(string $attributeName, string $format = ''): string |
||
66 | { |
||
67 | if (! $this->$attributeName) { |
||
68 | return ''; |
||
69 | } |
||
70 | |||
71 | if ($format === 'forHumans') { |
||
72 | return $this->$attributeName->diffForHumans(); |
||
73 | } |
||
74 | |||
75 | if ($format === '') { |
||
76 | $format = config('laravel-uptime-monitor.notifications.date_format'); |
||
77 | } |
||
78 | |||
79 | return $this->$attributeName->format($format); |
||
80 | } |
||
81 | } |
||
82 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: