blob: 74bbd20d8f405fc9aed75b7a53c66497d2759a6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<?php /* Copyright (c) 2024 Freya Murphy */
class Error_model extends Model {
private function get_msg(&$data, int $code)
{
http_response_code($code);
$data['title'] = $code;
$msg = status_code_msg($code);
if (!$msg && $code == 0)
$msg = lang('error_0');
if (!$msg) {
$error_text = lang('error', NULL);
$msg = $error_text[array_rand($error_text)];
$msg = sprintf($msg, $code);
}
$data['msg'] = $msg;
$data['desc'] = $msg;
}
public function get_error_data(int $code): array
{
$data = parent::get_data();
$this->get_msg($data, $code);
return $data;
}
}
|