1 | <?php |
||
9 | trait MonitorPresenter |
||
10 | { |
||
11 | public function getUptimeStatusAsEmojiAttribute(): string |
||
12 | { |
||
13 | if ($this->uptime_status === UptimeStatus::UP) { |
||
|
|||
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) { |
||
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 |
||
55 | |||
56 | public function getChunkedLastCertificateCheckFailureReasonAttribute(): string |
||
57 | { |
||
64 | |||
65 | protected function formatDate(string $attributeName, string $format = ''): string |
||
66 | { |
||
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: