| Total Complexity | 5 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class HomepageAccessibleCheck implements HealthCheck |
||
| 11 | { |
||
| 12 | public function check(): bool |
||
| 13 | { |
||
| 14 | return $this->get_http_response_code(Homepage::url()) == 200; |
||
| 15 | } |
||
| 16 | |||
| 17 | private function get_http_response_code(string $url) |
||
| 18 | { |
||
| 19 | if ($url == '') { |
||
| 20 | return false; |
||
| 21 | } |
||
| 22 | |||
| 23 | // Avoid ssl errors: SSL operation failed with code 1 |
||
| 24 | stream_context_set_default([ |
||
| 25 | 'ssl' => [ |
||
| 26 | 'verify_peer' => false, |
||
| 27 | 'verify_peer_name' => false, |
||
| 28 | ], |
||
| 29 | ]); |
||
| 30 | |||
| 31 | $headers = get_headers($url); |
||
| 32 | |||
| 33 | return substr($headers[0], 9, 3); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function message(): string |
||
| 39 | } |
||
| 40 | |||
| 41 | public function notifiers(): array |
||
| 48 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: