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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
<?php
namespace skin\error;
use Stringable;
function forbidden($ctx, $message) {
return $ctx->common(403, 'Forbidden', $message);
}
function not_found($ctx, $message) {
return $ctx->common(404, 'Not Found', $message);
}
function unauthorized($ctx, $message) {
return $ctx->common(401, 'Unauthorized', $message);
}
function not_implemented($ctx, $message) {
return $ctx->common(501, 'Not Implemented', $message);
}
function common($ctx,
int $code,
string|Stringable $title,
string|Stringable|null $message = null) {
return <<<HTML
<html>
<head><title>$code $title</title></head>
<body>
<center><h1>$code $title</h1></center>
{$ctx->if_true($message,
'<hr><p align="center">'.$message.'</p>'
)}
</body>
</html>
HTML;
}
|