1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Koded\Framework; |
4
|
|
|
|
5
|
|
|
use Koded\Http\Interfaces\HttpStatus; |
6
|
|
|
use function array_map; |
7
|
|
|
use function join; |
8
|
|
|
|
9
|
|
|
class HTTPNotFound extends HTTPError |
10
|
|
|
{ |
11
|
1 |
|
public function __construct(...$args) |
12
|
|
|
{ |
13
|
1 |
|
parent::__construct(HttpStatus::NOT_FOUND, ...$args); |
|
|
|
|
14
|
|
|
} |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
class HTTPBadRequest extends HTTPError |
18
|
|
|
{ |
19
|
|
|
public function __construct(...$args) |
20
|
|
|
{ |
21
|
|
|
parent::__construct(HttpStatus::BAD_REQUEST, ...$args); |
|
|
|
|
22
|
|
|
} |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
class HTTPMethodNotAllowed extends HTTPError |
26
|
|
|
{ |
27
|
2 |
|
public function __construct(array $allowed, ...$args) |
28
|
|
|
{ |
29
|
2 |
|
$args['headers']['Allow'] = join(',', array_map('strtoupper', $allowed)); |
30
|
2 |
|
parent::__construct(HttpStatus::METHOD_NOT_ALLOWED, ...$args); |
|
|
|
|
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
class HTTPConflict extends HTTPError |
35
|
|
|
{ |
36
|
7 |
|
public function __construct(...$args) |
37
|
|
|
{ |
38
|
7 |
|
parent::__construct(HttpStatus::CONFLICT, ...$args); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
class HTTPServiceNotFound extends HTTPError |
43
|
|
|
{ |
44
|
|
|
public function __construct(...$args) |
45
|
|
|
{ |
46
|
|
|
parent::__construct(HttpStatus::SERVICE_NOT_FOUND, ...$args); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
class HTTPUnsupportedMediaType extends HTTPError |
51
|
|
|
{ |
52
|
|
|
public function __construct(...$args) |
53
|
|
|
{ |
54
|
|
|
parent::__construct(HttpStatus::UNSUPPORTED_MEDIA_TYPE, ...$args); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
class HTTPUnprocessableEntity extends HTTPError |
59
|
|
|
{ |
60
|
|
|
public function __construct(...$args) |
61
|
|
|
{ |
62
|
|
|
parent::__construct(HttpStatus::UNPROCESSABLE_ENTITY, ...$args); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
class HTTPFailedDependency extends HTTPError |
67
|
|
|
{ |
68
|
|
|
public function __construct(...$args) |
69
|
|
|
{ |
70
|
|
|
parent::__construct(HttpStatus::FAILED_DEPENDENCY, ...$args); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
class HTTPUnauthorized extends HTTPError |
75
|
|
|
{ |
76
|
|
|
public function __construct(...$args) |
77
|
|
|
{ |
78
|
|
|
parent::__construct(HttpStatus::UNAUTHORIZED, ...$args); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
class HTTPForbidden extends HTTPError |
83
|
|
|
{ |
84
|
|
|
public function __construct(...$args) |
85
|
|
|
{ |
86
|
|
|
parent::__construct(HttpStatus::FORBIDDEN, ...$args); |
|
|
|
|
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
class HTTPNotImplemented extends HTTPError |
91
|
|
|
{ |
92
|
1 |
|
public function __construct(...$args) |
93
|
|
|
{ |
94
|
1 |
|
parent::__construct(HttpStatus::NOT_IMPLEMENTED, ...$args); |
|
|
|
|
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
class HTTPServerError extends HTTPError |
99
|
|
|
{ |
100
|
|
|
public function __construct(...$args) |
101
|
|
|
{ |
102
|
|
|
parent::__construct(HttpStatus::INTERNAL_SERVER_ERROR, ...$args); |
|
|
|
|
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|