|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +namespace Parable\Http; |
| 4 | + |
| 5 | +use MyCLabs\Enum\Enum; |
| 6 | + |
| 7 | +/** |
| 8 | + * @method static HttpStatusCode _100 |
| 9 | + * @method static HttpStatusCode _101 |
| 10 | + * @method static HttpStatusCode _200 |
| 11 | + * @method static HttpStatusCode _201 |
| 12 | + * @method static HttpStatusCode _202 |
| 13 | + * @method static HttpStatusCode _203 |
| 14 | + * @method static HttpStatusCode _204 |
| 15 | + * @method static HttpStatusCode _205 |
| 16 | + * @method static HttpStatusCode _206 |
| 17 | + * @method static HttpStatusCode _300 |
| 18 | + * @method static HttpStatusCode _301 |
| 19 | + * @method static HttpStatusCode _302 |
| 20 | + * @method static HttpStatusCode _303 |
| 21 | + * @method static HttpStatusCode _304 |
| 22 | + * @method static HttpStatusCode _305 |
| 23 | + * @method static HttpStatusCode _307 |
| 24 | + * @method static HttpStatusCode _308 |
| 25 | + * @method static HttpStatusCode _400 |
| 26 | + * @method static HttpStatusCode _401 |
| 27 | + * @method static HttpStatusCode _402 |
| 28 | + * @method static HttpStatusCode _403 |
| 29 | + * @method static HttpStatusCode _404 |
| 30 | + * @method static HttpStatusCode _405 |
| 31 | + * @method static HttpStatusCode _406 |
| 32 | + * @method static HttpStatusCode _407 |
| 33 | + * @method static HttpStatusCode _408 |
| 34 | + * @method static HttpStatusCode _409 |
| 35 | + * @method static HttpStatusCode _410 |
| 36 | + * @method static HttpStatusCode _411 |
| 37 | + * @method static HttpStatusCode _412 |
| 38 | + * @method static HttpStatusCode _413 |
| 39 | + * @method static HttpStatusCode _414 |
| 40 | + * @method static HttpStatusCode _415 |
| 41 | + * @method static HttpStatusCode _416 |
| 42 | + * @method static HttpStatusCode _417 |
| 43 | + * @method static HttpStatusCode _418 |
| 44 | + * @method static HttpStatusCode _421 |
| 45 | + * @method static HttpStatusCode _426 |
| 46 | + * @method static HttpStatusCode _428 |
| 47 | + * @method static HttpStatusCode _429 |
| 48 | + * @method static HttpStatusCode _431 |
| 49 | + * @method static HttpStatusCode _451 |
| 50 | + * @method static HttpStatusCode _500 |
| 51 | + * @method static HttpStatusCode _501 |
| 52 | + * @method static HttpStatusCode _502 |
| 53 | + * @method static HttpStatusCode _503 |
| 54 | + * @method static HttpStatusCode _504 |
| 55 | + * @method static HttpStatusCode _505 |
| 56 | + * @method static HttpStatusCode _506 |
| 57 | + * @method static HttpStatusCode _507 |
| 58 | + * @method static HttpStatusCode _511 |
| 59 | + */ |
| 60 | +class HttpStatusCode extends Enum |
| 61 | +{ |
| 62 | + private const _100 = 100; |
| 63 | + private const _101 = 101; |
| 64 | + private const _200 = 200; |
| 65 | + private const _201 = 201; |
| 66 | + private const _202 = 202; |
| 67 | + private const _203 = 203; |
| 68 | + private const _204 = 204; |
| 69 | + private const _205 = 205; |
| 70 | + private const _206 = 206; |
| 71 | + private const _300 = 300; |
| 72 | + private const _301 = 301; |
| 73 | + private const _302 = 302; |
| 74 | + private const _303 = 303; |
| 75 | + private const _304 = 304; |
| 76 | + private const _305 = 305; |
| 77 | + private const _307 = 307; |
| 78 | + private const _308 = 308; |
| 79 | + private const _400 = 400; |
| 80 | + private const _401 = 401; |
| 81 | + private const _402 = 402; |
| 82 | + private const _403 = 403; |
| 83 | + private const _404 = 404; |
| 84 | + private const _405 = 405; |
| 85 | + private const _406 = 406; |
| 86 | + private const _407 = 407; |
| 87 | + private const _408 = 408; |
| 88 | + private const _409 = 409; |
| 89 | + private const _410 = 410; |
| 90 | + private const _411 = 411; |
| 91 | + private const _412 = 412; |
| 92 | + private const _413 = 413; |
| 93 | + private const _414 = 414; |
| 94 | + private const _415 = 415; |
| 95 | + private const _416 = 416; |
| 96 | + private const _417 = 417; |
| 97 | + private const _418 = 418; |
| 98 | + private const _421 = 421; |
| 99 | + private const _426 = 426; |
| 100 | + private const _428 = 428; |
| 101 | + private const _429 = 429; |
| 102 | + private const _431 = 431; |
| 103 | + private const _451 = 451; |
| 104 | + private const _500 = 500; |
| 105 | + private const _501 = 501; |
| 106 | + private const _502 = 502; |
| 107 | + private const _503 = 503; |
| 108 | + private const _504 = 504; |
| 109 | + private const _505 = 505; |
| 110 | + private const _506 = 506; |
| 111 | + private const _507 = 507; |
| 112 | + private const _511 = 511; |
| 113 | + |
| 114 | + public function getText(): string |
| 115 | + { |
| 116 | + return match ($this->getValue()) { |
| 117 | + static::_100 => "Continue", |
| 118 | + static::_101 => "Switching Protocols", |
| 119 | + static::_200 => "OK", |
| 120 | + static::_201 => "Created", |
| 121 | + static::_202 => "Accepted", |
| 122 | + static::_203 => "Non-Authoritative Information", |
| 123 | + static::_204 => "No Content", |
| 124 | + static::_205 => "Reset Content", |
| 125 | + static::_206 => "Partial Content", |
| 126 | + static::_300 => "Multiple Choice", |
| 127 | + static::_301 => "Moved Permanently", |
| 128 | + static::_302 => "Found", |
| 129 | + static::_303 => "See Other", |
| 130 | + static::_304 => "Not Modified", |
| 131 | + static::_305 => "Use Proxy", |
| 132 | + static::_307 => "Temporary Redirect", |
| 133 | + static::_308 => "Permanent Redirect", |
| 134 | + static::_400 => "Bad Request", |
| 135 | + static::_401 => "Unauthorized", |
| 136 | + static::_402 => "Payment Required", |
| 137 | + static::_403 => "Forbidden", |
| 138 | + static::_404 => "Not Found", |
| 139 | + static::_405 => "Method Not Allowed", |
| 140 | + static::_406 => "Not Acceptable", |
| 141 | + static::_407 => "Proxy Authentication Required", |
| 142 | + static::_408 => "Request Timeout", |
| 143 | + static::_409 => "Conflict", |
| 144 | + static::_410 => "Gone", |
| 145 | + static::_411 => "Length Required", |
| 146 | + static::_412 => "Precondition Failed", |
| 147 | + static::_413 => "Payload Too Large", |
| 148 | + static::_414 => "URI Too Long", |
| 149 | + static::_415 => "Unsupported Media Type", |
| 150 | + static::_416 => "Requested Range Not Satisfiable", |
| 151 | + static::_417 => "Expectation Failed", |
| 152 | + static::_418 => "I'm a teapot", |
| 153 | + static::_421 => "Misdirected Request", |
| 154 | + static::_426 => "Upgrade Required", |
| 155 | + static::_428 => "Precondition Required", |
| 156 | + static::_429 => "Too Many Requests", |
| 157 | + static::_431 => "Request Header Fields Too Large", |
| 158 | + static::_451 => "Unavailable For Legal Reasons", |
| 159 | + static::_500 => "Internal Server Error", |
| 160 | + static::_501 => "Not Implemented", |
| 161 | + static::_502 => "Bad Gateway", |
| 162 | + static::_503 => "Service Unavailable", |
| 163 | + static::_504 => "Gateway Timeout", |
| 164 | + static::_505 => "HTTP Version Not Supported", |
| 165 | + static::_506 => "Variant Also Negotiates", |
| 166 | + static::_507 => "Variant Also Negotiates", |
| 167 | + static::_511 => "Network Authentication Required", |
| 168 | + default => throw new HttpException('Unknown status code: ' . $this->getValue()), |
| 169 | + }; |
| 170 | + } |
| 171 | +} |
0 commit comments