|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Blitz PHP framework. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2022 Dimitri Sitchet Tomkeu <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view |
|
9
|
|
|
* the LICENSE file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace BlitzPHP\Exceptions; |
|
13
|
|
|
|
|
14
|
|
|
class HttpException extends FrameworkException |
|
15
|
|
|
{ |
|
16
|
|
|
public static function methodNotAllowed(string $method): self |
|
17
|
|
|
{ |
|
18
|
|
|
return new static(self::lang('HTTP.methodNotAllowed', [$method])); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public static function invalidStatusCode(int $code) |
|
22
|
|
|
{ |
|
23
|
2 |
|
return new static(lang('HTTP.invalidStatusCode', [$code])); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public static function unkownStatusCode(int $code) |
|
27
|
|
|
{ |
|
28
|
2 |
|
return new static(lang('HTTP.unknownStatusCode', [$code])); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public static function invalidRedirectRoute(string $route) |
|
32
|
|
|
{ |
|
33
|
4 |
|
return new static(lang('HTTP.invalidRoute', [$route])); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public static function badRequest(string $message = 'Bad Request') |
|
37
|
|
|
{ |
|
38
|
|
|
return new static($message, 400); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public static function unableToParseURI(string $uri) |
|
42
|
|
|
{ |
|
43
|
4 |
|
return new static(lang('HTTP.cannotParseURI', [$uri])); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public static function uriSegmentOutOfRange(int $segment) |
|
47
|
|
|
{ |
|
48
|
2 |
|
return new static(lang('HTTP.segmentOutOfRange', [$segment])); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public static function invalidPort(int $port) |
|
52
|
|
|
{ |
|
53
|
2 |
|
return new static(lang('HTTP.invalidPort', [$port])); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public static function malformedQueryString() |
|
57
|
|
|
{ |
|
58
|
|
|
return new static(lang('HTTP.malformedQueryString')); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|