Skip to content

Commit e156adb

Browse files
committed
Adding the StatusCodeInterface
the StatusCodeInterface Interface defines constant for common HTTP Status code The interface lists all common HTTP Status Code from different RFC
1 parent 26095c6 commit e156adb

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

src/StatusCodeInterface.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
3+
namespace Fig\Http\Message;
4+
5+
/**
6+
* Defines constants for common HTTP status code.
7+
*
8+
* @see https://tools.ietf.org/html/rfc2518#section-9.7
9+
* @see https://tools.ietf.org/html/rfc2295#section-8.1
10+
* @see https://tools.ietf.org/html/rfc2774#section-7
11+
* @see https://tools.ietf.org/html/rfc3229#section-10.4
12+
* @see https://tools.ietf.org/html/rfc4918#section-11
13+
* @see https://tools.ietf.org/html/rfc5842#section-7.1
14+
* @see https://tools.ietf.org/html/rfc5842#section-7.2
15+
* @see https://tools.ietf.org/html/rfc6585#section-3
16+
* @see https://tools.ietf.org/html/rfc6585#section-4
17+
* @see https://tools.ietf.org/html/rfc6585#section-5
18+
* @see https://tools.ietf.org/html/rfc6585#section-6
19+
* @see https://tools.ietf.org/html/rfc7231#section-6
20+
* @see https://tools.ietf.org/html/rfc7238#section-3
21+
* @see https://tools.ietf.org/html/rfc7725#section-3
22+
*
23+
* Usage:
24+
*
25+
* <code>
26+
* class ResponseFactory implements StatusCodeInterface
27+
* {
28+
* public function createResponse($code = self::STATUS_OK)
29+
* {
30+
* }
31+
* }
32+
* </code>
33+
*/
34+
interface StatusCodeInterface
35+
{
36+
//Informational 1xx
37+
const STATUS_CONTINUE = 100;
38+
const STATUS_SWITCHING_PROTOCOLS = 101;
39+
const STATUS_PROCESSING = 102;
40+
//Successful 2xx
41+
const STATUS_OK = 200;
42+
const STATUS_CREATED = 201;
43+
const STATUS_ACCEPTED = 202;
44+
const STATUS_NON_AUTHORITATIVE_INFORMATION = 203;
45+
const STATUS_NO_CONTENT = 204;
46+
const STATUS_RESET_CONTENT = 205;
47+
const STATUS_PARTIAL_CONTENT = 206;
48+
const STATUS_MULTI_STATUS = 207;
49+
const STATUS_ALREADY_REPORTED = 208;
50+
const STATUS_IM_USED = 226;
51+
//Redirection 3xx
52+
const STATUS_MULTIPLE_CHOICES = 300;
53+
const STATUS_MOVED_PERMANENTLY = 301;
54+
const STATUS_FOUND = 302;
55+
const STATUS_SEE_OTHER = 303;
56+
const STATUS_NOT_MODIFIED = 304;
57+
const STATUS_USE_PROXY = 305;
58+
const STATUS_RESERVED = 306;
59+
const STATUS_TEMPORARY_REDIRECT = 307;
60+
const STATUS_PERMANENT_REDIRECT = 308;
61+
//Client Error 4xx
62+
const STATUS_BAD_REQUEST = 400;
63+
const STATUS_UNAUTHORIZED = 401;
64+
const STATUS_PAYMENT_REQUIRED = 402;
65+
const STATUS_FORBIDDEN = 403;
66+
const STATUS_NOT_FOUND = 404;
67+
const STATUS_METHOD_NOT_ALLOWED = 405;
68+
const STATUS_NOT_ACCEPTABLE = 406;
69+
const STATUS_PROXY_AUTHENTICATION_REQUIRED = 407;
70+
const STATUS_REQUEST_TIMEOUT = 408;
71+
const STATUS_CONFLICT = 409;
72+
const STATUS_GONE = 410;
73+
const STATUS_LENGTH_REQUIRED = 411;
74+
const STATUS_PRECONDITION_FAILED = 412;
75+
const STATUS_PAYLOAD_TOO_LARGE = 413;
76+
const STATUS_URI_TOO_LONG = 414;
77+
const STATUS_UNSUPPORTED_MEDIA_TYPE = 415;
78+
const STATUS_RANGE_NOT_SATISFIABLE = 416;
79+
const STATUS_EXPECTATION_FAILED = 417;
80+
const STATUS_UNPROCESSABLE_ENTITY = 422;
81+
const STATUS_LOCKED = 423;
82+
const STATUS_FAILED_DEPENDENCY = 424;
83+
const STATUS_UPGRADE_REQUIRED = 426;
84+
const STATUS_PRECONDITION_REQUIRED = 428;
85+
const STATUS_TOO_MANY_REQUESTS = 429;
86+
const STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
87+
const STATUS_UNAVAILABLE_FOR_LEGAL_REASONS = 451;
88+
//Server Error 5xx
89+
const STATUS_INTERNAL_SERVER_ERROR = 500;
90+
const STATUS_NOT_IMPLEMENTED = 501;
91+
const STATUS_BAD_GATEWAY = 502;
92+
const STATUS_SERVICE_UNAVAILABLE = 503;
93+
const STATUS_GATEWAY_TIMEOUT = 504;
94+
const STATUS_VERSION_NOT_SUPPORTED = 505;
95+
const STATUS_VARIANT_ALSO_NEGOTIATES = 506;
96+
const STATUS_INSUFFICIENT_STORAGE = 507;
97+
const STATUS_LOOP_DETECTED = 508;
98+
const STATUS_NOT_EXTENDED = 510;
99+
const STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511;
100+
}

0 commit comments

Comments
 (0)