1 | <?php |
||
14 | trait SupportsCertificateCheck |
||
15 | { |
||
16 | public function checkCertificate() |
||
26 | |||
27 | public function setCertificate(SslCertificate $certificate) |
||
28 | { |
||
29 | $this->certificate_status = $certificate->isValid($this->url) |
||
30 | ? CertificateStatus::VALID |
||
31 | : CertificateStatus::INVALID; |
||
32 | |||
33 | $this->certificate_expiration_date = $certificate->expirationDate(); |
||
34 | $this->certificate_issuer = $certificate->getIssuer(); |
||
35 | $this->save(); |
||
36 | |||
37 | $this->fireEventsForUpdatedMonitorWithCertificate($this, $certificate); |
||
38 | } |
||
39 | |||
40 | public function setCertificateException(Exception $exception) |
||
41 | { |
||
42 | $this->certificate_status = CertificateStatus::INVALID; |
||
43 | $this->certificate_expiration_date = null; |
||
44 | $this->certificate_issuer = ''; |
||
45 | $this->certificate_check_failure_reason = $exception->getMessage(); |
||
46 | $this->save(); |
||
47 | |||
48 | event(new CertificateCheckFailed($this, $exception->getMessage())); |
||
49 | } |
||
50 | |||
51 | protected function fireEventsForUpdatedMonitorWithCertificate(Monitor $monitor, SslCertificate $certificate) |
||
77 | } |
||
78 |
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: