| Conditions | 4 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 4 | function response_code($code, $view_and_exit = true, $view_name = false) { |
||
|
|
|||
| 5 | http_response_code($code); |
||
| 6 | if ($view_and_exit) { |
||
| 7 | if (empty($view_name)) { |
||
| 8 | $view_name = strval($code); |
||
| 9 | } |
||
| 10 | // Check if a dedicated view exists; if not, load common error view |
||
| 11 | $dedicated_view = $this->load_view($view_name, [ |
||
| 12 | 'error_code' => $code, |
||
| 13 | ]); |
||
| 14 | if (! $dedicated_view) { |
||
| 15 | $this->load_view('http_error', [ |
||
| 16 | 'error_code' => $code, |
||
| 17 | ]); |
||
| 18 | } |
||
| 19 | exit(); |
||
| 20 | } |
||
| 33 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.