http

Форк
0
/
Status.php 
151 строка · 8.8 Кб
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Upside\Http;
6

7
enum Status: int
8
{
9
    //1xx
10
    case CONTINUE                             = 100;
11
    case SWITCHING_PROTOCOLS                  = 101;
12
    case PROCESSING                           = 102; // RFC2518
13
    case EARLY_HINTS                          = 103; // RFC8297
14
    //2xx
15
    case OK                                   = 200;
16
    case CREATED                              = 201;
17
    case ACCEPTED                             = 202;
18
    case NON_AUTHORITATIVE_INFORMATION        = 203;
19
    case NO_CONTENT                           = 204;
20
    case RESET_CONTENT                        = 205;
21
    case PARTIAL_CONTENT                      = 206;
22
    case MULTI_STATUS                         = 207; // RFC4918
23
    case ALREADY_REPORTED                     = 208; // RFC5842
24
    case IM_USED                              = 226; // RFC3229
25
    //3xx
26
    case MULTIPLE_CHOICES                     = 300;
27
    case MOVED_PERMANENTLY                    = 301;
28
    case FOUND                                = 302;
29
    case SEE_OTHER                            = 303;
30
    case NOT_MODIFIED                         = 304;
31
    case USE_PROXY                            = 305;
32
    case RESERVED                             = 306;
33
    case TEMPORARY_REDIRECT                   = 307;
34
    case PERMANENTLY_REDIRECT                 = 308; // RFC7238
35
    //4xx
36
    case BAD_REQUEST                          = 400;
37
    case UNAUTHORIZED                         = 401;
38
    case PAYMENT_REQUIRED                     = 402;
39
    case FORBIDDEN                            = 403;
40
    case NOT_FOUND                            = 404;
41
    case METHOD_NOT_ALLOWED                   = 405;
42
    case NOT_ACCEPTABLE                       = 406;
43
    case PROXY_AUTHENTICATION_REQUIRED        = 407;
44
    case REQUEST_TIMEOUT                      = 408;
45
    case CONFLICT                             = 409;
46
    case GONE                                 = 410;
47
    case LENGTH_REQUIRED                      = 411;
48
    case PRECONDITION_FAILED                  = 412;
49
    case REQUEST_ENTITY_TOO_LARGE             = 413;
50
    case REQUEST_URI_TOO_LONG                 = 414;
51
    case UNSUPPORTED_MEDIA_TYPE               = 415;
52
    case REQUESTED_RANGE_NOT_SATISFIABLE      = 416;
53
    case EXPECTATION_FAILED                   = 417;
54
    case I_AM_A_TEAPOT                        = 418; // RFC2324
55
    case MISDIRECTED_REQUEST                  = 421; // RFC7540
56
    case UNPROCESSABLE_ENTITY                 = 422; // RFC4918
57
    case LOCKED                               = 423; // RFC4918
58
    case FAILED_DEPENDENCY                    = 424; // RFC4918
59
    case TOO_EARLY                            = 425; // RFC-ietf-httpbis-replay-04
60
    case UPGRADE_REQUIRED                     = 426; // RFC2817
61
    case PRECONDITION_REQUIRED                = 428; // RFC6585
62
    case TOO_MANY_REQUESTS                    = 429; // RFC6585
63
    case REQUEST_HEADER_FIELDS_TOO_LARGE      = 431; // RFC6585
64
    case UNAVAILABLE_FOR_LEGAL_REASONS        = 451; // RFC7725
65
    //5xx
66
    case INTERNAL_SERVER_ERROR                = 500;
67
    case NOT_IMPLEMENTED                      = 501;
68
    case BAD_GATEWAY                          = 502;
69
    case SERVICE_UNAVAILABLE                  = 503;
70
    case GATEWAY_TIMEOUT                      = 504;
71
    case VERSION_NOT_SUPPORTED                = 505;
72
    case VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295
73
    case INSUFFICIENT_STORAGE                 = 507; // RFC4918
74
    case LOOP_DETECTED                        = 508; // RFC5842
75
    case NOT_EXTENDED                         = 510; // RFC2774
76
    case NETWORK_AUTHENTICATION_REQUIRED      = 511; // RFC6585
77

78
    public function code(): int
79
    {
80
        return $this->value;
81
    }
82

83
    public function text(): string
84
    {
85
        return match ($this) {
86
            self::CONTINUE                             => 'Continue',
87
            self::SWITCHING_PROTOCOLS                  => 'Switching Protocols',
88
            self::PROCESSING                           => 'Processing', // RFC2518
89
            self::EARLY_HINTS                          => 'Early Hints',
90
            self::OK                                   => 'OK',
91
            self::CREATED                              => 'Created',
92
            self::ACCEPTED                             => 'Accepted',
93
            self::NON_AUTHORITATIVE_INFORMATION        => 'Non-Authoritative Information',
94
            self::NO_CONTENT                           => 'No Content',
95
            self::RESET_CONTENT                        => 'Reset Content',
96
            self::PARTIAL_CONTENT                      => 'Partial Content',
97
            self::MULTI_STATUS                         => 'Multi-Status', // RFC4918
98
            self::ALREADY_REPORTED                     => 'Already Reported', // RFC5842
99
            self::IM_USED                              => 'IM Used', // RFC3229
100
            self::MULTIPLE_CHOICES                     => 'Multiple Choices',
101
            self::MOVED_PERMANENTLY                    => 'Moved Permanently',
102
            self::FOUND                                => 'Found',
103
            self::SEE_OTHER                            => 'See Other',
104
            self::NOT_MODIFIED                         => 'Not Modified',
105
            self::USE_PROXY                            => 'Use Proxy',
106
            self::RESERVED                             => 'unknown status',
107
            self::TEMPORARY_REDIRECT                   => 'Temporary Redirect',
108
            self::PERMANENTLY_REDIRECT                 => 'Permanent Redirect', // RFC7238
109
            self::BAD_REQUEST                          => 'Bad Request',
110
            self::UNAUTHORIZED                         => 'Unauthorized',
111
            self::PAYMENT_REQUIRED                     => 'Payment Required',
112
            self::FORBIDDEN                            => 'Forbidden',
113
            self::NOT_FOUND                            => 'Not Found',
114
            self::METHOD_NOT_ALLOWED                   => 'Method Not Allowed',
115
            self::NOT_ACCEPTABLE                       => 'Not Acceptable',
116
            self::PROXY_AUTHENTICATION_REQUIRED        => 'Proxy Authentication Required',
117
            self::REQUEST_TIMEOUT                      => 'Request Timeout',
118
            self::CONFLICT                             => 'Conflict',
119
            self::GONE                                 => 'Gone',
120
            self::LENGTH_REQUIRED                      => 'Length Required',
121
            self::PRECONDITION_FAILED                  => 'Precondition Failed',
122
            self::REQUEST_ENTITY_TOO_LARGE             => 'Content Too Large', // RFC-ietf-httpbis-semantics
123
            self::REQUEST_URI_TOO_LONG                 => 'URI Too Long',
124
            self::UNSUPPORTED_MEDIA_TYPE               => 'Unsupported Media Type',
125
            self::REQUESTED_RANGE_NOT_SATISFIABLE      => 'Range Not Satisfiable',
126
            self::EXPECTATION_FAILED                   => 'Expectation Failed',
127
            self::I_AM_A_TEAPOT                        => 'I\'m a teapot', // RFC2324
128
            self::MISDIRECTED_REQUEST                  => 'Misdirected Request', // RFC7540
129
            self::UNPROCESSABLE_ENTITY                 => 'Unprocessable Content', // RFC-ietf-httpbis-semantics
130
            self::LOCKED                               => 'Locked', // RFC4918
131
            self::FAILED_DEPENDENCY                    => 'Failed Dependency', // RFC4918
132
            self::TOO_EARLY                            => 'Too Early', // RFC-ietf-httpbis-replay-04
133
            self::UPGRADE_REQUIRED                     => 'Upgrade Required', // RFC2817
134
            self::PRECONDITION_REQUIRED                => 'Precondition Required', // RFC6585
135
            self::TOO_MANY_REQUESTS                    => 'Too Many Requests', // RFC6585
136
            self::REQUEST_HEADER_FIELDS_TOO_LARGE      => 'Request Header Fields Too Large', // RFC6585
137
            self::UNAVAILABLE_FOR_LEGAL_REASONS        => 'Unavailable For Legal Reasons', // RFC7725
138
            self::INTERNAL_SERVER_ERROR                => 'Internal Server Error',
139
            self::NOT_IMPLEMENTED                      => 'Not Implemented',
140
            self::BAD_GATEWAY                          => 'Bad Gateway',
141
            self::SERVICE_UNAVAILABLE                  => 'Service Unavailable',
142
            self::GATEWAY_TIMEOUT                      => 'Gateway Timeout',
143
            self::VERSION_NOT_SUPPORTED                => 'HTTP Version Not Supported',
144
            self::VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL => 'Variant Also Negotiates', // RFC2295
145
            self::INSUFFICIENT_STORAGE                 => 'Insufficient Storage', // RFC4918
146
            self::LOOP_DETECTED                        => 'Loop Detected', // RFC5842
147
            self::NOT_EXTENDED                         => 'Not Extended', // RFC2774
148
            self::NETWORK_AUTHENTICATION_REQUIRED      => 'Network Authentication Required', // RFC6585
149
        };
150
    }
151
}
152

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.