• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 11293799095

11 Oct 2024 02:04PM UTC coverage: 82.102% (-0.03%) from 82.134%
11293799095

Pull #556

github

web-flow
Merge a4adeb52f into c1233aa56
Pull Request #556: fix(phpstan): fix phpstan issues

5 of 9 new or added lines in 3 files covered. (55.56%)

1 existing line in 1 file now uncovered.

6757 of 8230 relevant lines covered (82.1%)

38.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.44
/src/Tempest/Http/src/Status.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Http;
6

7
enum Status: int
8
{
9
    // Informational
10
    case CONTINUE = 100;
11
    case SWITCHING_PROTOCOLS = 101;
12
    case PROCESSING = 102;
13
    case EARLY_HINTS = 103;
14

15
    // Successful
16
    case OK = 200;
17
    case CREATED = 201;
18
    case ACCEPTED = 202;
19
    case NON_AUTHORITATIVE_INFORMATION = 203;
20
    case NO_CONTENT = 204;
21
    case RESET_CONTENT = 205;
22
    case PARTIAL_CONTENT = 206;
23
    case MULTI_STATUS = 207;
24
    case ALREADY_REPORTED = 208;
25
    case IM_USED = 226;
26

27
    // Redirection
28
    case MULTIPLE_CHOICES = 300;
29
    case MOVED_PERMANENTLY = 301;
30
    case FOUND = 302;
31
    case SEE_OTHER = 303;
32
    case NOT_MODIFIED = 304;
33
    case USE_PROXY = 305;
34
    case UNUSED = 306;
35
    case TEMPORARY_REDIRECT = 307;
36
    case PERMANENT_REDIRECT = 308;
37

38
    // Client errors
39
    case BAD_REQUEST = 400;
40
    case UNAUTHORIZED = 401;
41
    case PAYMENT_REQUIRED = 402;
42
    case FORBIDDEN = 403;
43
    case NOT_FOUND = 404;
44
    case METHOD_NOT_ALLOWED = 405;
45
    case NOT_ACCEPTABLE = 406;
46
    case PROXY_AUTHENTICATION_REQUIRED = 407;
47
    case REQUEST_TIMEOUT = 408;
48
    case CONFLICT = 409;
49
    case GONE = 410;
50
    case LENGTH_REQUIRED = 411;
51
    case PRECONDITION_FAILED = 412;
52
    case CONTENT_TOO_LARGE = 413;
53
    case URI_TOO_LONG = 414;
54
    case UNSUPPORTED_MEDIA_TYPE = 415;
55
    case RANGE_NOT_SATISFIABLE = 416;
56
    case EXPECTATION_FAILED = 417;
57
    case IM_A_TEAPOT = 418;
58
    case MISDIRECTED_REQUEST = 421;
59
    case UNPROCESSABLE_CONTENT = 422;
60
    case LOCKED = 423;
61
    case FAILED_DEPENDENCY = 424;
62
    case TOO_EARLY = 425;
63
    case UPGRADE_REQUIRED = 426;
64
    case PRECONDITION_REQUIRED = 428;
65
    case TOO_MANY_REQUESTS = 429;
66
    case REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
67
    case UNAVAILABLE_FOR_LEGAL_REASONS = 451;
68

69
    // Server Responses
70
    case INTERNAL_SERVER_ERROR = 500;
71
    case NOT_IMPLEMENTED = 501;
72
    case BAD_GATEWAY = 502;
73
    case SERVICE_UNAVAILABLE = 503;
74
    case GATEWAY_TIMEOUT = 504;
75
    case HTTP_VERSION_NOT_SUPPORTED = 505;
76
    case VARIANT_ALSO_NEGOTIATES = 506;
77
    case INSUFFICIENT_STORAGE = 507;
78
    case LOOP_DETECTED = 508;
79
    case NOT_EXTENDED = 510;
80
    case NETWORK_AUTHENTICATION_REQUIRED = 511;
81

82
    public static function code(int $code): self
71✔
83
    {
84
        return self::from($code);
71✔
85
    }
86

87
    public function description(): string
61✔
88
    {
89
        return match ($this->value) {
61✔
90
            100 => 'Continue',
1✔
91
            101 => 'Switching Protocols',
1✔
92
            102 => 'Processing',
1✔
93
            103 => 'Early Hints',
1✔
94

95
            200 => 'OK',
1✔
96
            201 => 'Created',
1✔
97
            202 => 'Accepted',
1✔
98
            203 => 'Non-Authoritative Information',
1✔
99
            204 => 'No Content',
1✔
100
            205 => 'Reset Content',
1✔
101
            206 => 'Partial Content',
1✔
102
            207 => 'Multi-Status',
1✔
103
            208 => 'Already Reported',
1✔
104
            226 => 'IM Used',
1✔
105

106
            300 => 'Multiple Choices',
1✔
107
            301 => 'Moved Permanently',
1✔
108
            302 => 'Found',
1✔
109
            303 => 'See Other',
1✔
110
            304 => 'Not Modified',
1✔
111
            305 => 'Use Proxy',
1✔
NEW
112
            306 => 'Unused',
×
113
            307 => 'Temporary Redirect',
1✔
114
            308 => 'Permanent Redirect',
1✔
115

116
            400 => 'Bad Request',
1✔
117
            401 => 'Unauthorized',
1✔
118
            402 => 'Payment Required',
1✔
119
            403 => 'Forbidden',
1✔
120
            404 => 'Not Found',
1✔
121
            405 => 'Method Not Allowed',
1✔
122
            406 => 'Not Acceptable',
1✔
123
            407 => 'Proxy Authentication Required',
1✔
124
            408 => 'Request Timeout',
1✔
125
            409 => 'Conflict',
1✔
126
            410 => 'Gone',
1✔
127
            411 => 'Length Required',
1✔
128
            412 => 'Precondition Failed',
1✔
129
            413 => 'Content Too Large',
1✔
130
            414 => 'URI Too Long',
1✔
131
            415 => 'Unsupported Media Type',
1✔
132
            416 => 'Range Not Satisfiable',
1✔
133
            417 => 'Expectation Failed',
1✔
NEW
134
            418 => 'I Am A Teapot',
×
135
            421 => 'Misdirected Request',
1✔
136
            422 => 'Unprocessable Content',
1✔
137
            423 => 'Locked',
1✔
138
            424 => 'Failed Dependency',
1✔
139
            425 => 'Too Early',
1✔
140
            426 => 'Upgrade Required',
1✔
141
            428 => 'Precondition Required',
1✔
142
            429 => 'Too Many Requests',
1✔
143
            431 => 'Request Header Fields Too Large',
1✔
144
            451 => 'Unavailable For Legal Reasons',
1✔
145

146
            500 => 'Internal Server Error',
1✔
147
            501 => 'Not Implemented',
1✔
148
            502 => 'Bad Gateway',
1✔
149
            503 => 'Service Unavailable',
1✔
150
            504 => 'Gateway Timeout',
1✔
151
            505 => 'HTTP Version Not Supported',
1✔
152
            506 => 'Variant Also Negotiates',
1✔
153
            507 => 'Insufficient Storage',
1✔
154
            508 => 'Loop Detected',
1✔
155
            510 => 'Not Extended',
1✔
156
            511 => 'Network Authentication Required',
61✔
157
        };
61✔
158
    }
159

160
    public function isInformational(): bool
61✔
161
    {
162
        return $this->value < 200;
61✔
163
    }
164

165
    public function isSuccessful(): bool
61✔
166
    {
167
        return $this->value >= 200 && $this->value < 300;
61✔
168
    }
169

170
    public function isRedirect(): bool
67✔
171
    {
172
        return $this->value >= 300 && $this->value < 400;
67✔
173
    }
174

175
    public function isClientError(): bool
61✔
176
    {
177
        return $this->value >= 400 && $this->value < 500;
61✔
178
    }
179

180
    public function isServerError(): bool
61✔
181
    {
182
        return $this->value >= 500;
61✔
183
    }
184
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc