@@ -36,4 +36,59 @@ public static function getUserThemeMode(User $user): string
36
36
37
37
return $ mode ;
38
38
}
39
+
40
+ /**
41
+ * httpStatusCodetoString translates a HTTP status code to a readable message
42
+ *
43
+ * @param int $code HTTP status code
44
+ * @return string
45
+ */
46
+ public static function httpStatusCodetoString (int $ code = 0 ): string
47
+ {
48
+ $ statuscodes = [
49
+ '100 ' => 'Continue ' ,
50
+ '101 ' => 'Switching Protocols ' ,
51
+ '200 ' => 'OK ' ,
52
+ '201 ' => 'Created ' ,
53
+ '202 ' => 'Accepted ' ,
54
+ '203 ' => 'Non-Authoritative Information ' ,
55
+ '204 ' => 'No Content ' ,
56
+ '205 ' => 'Reset Content ' ,
57
+ '206 ' => 'Partial Content ' ,
58
+ '300 ' => 'Multiple Choices ' ,
59
+ '302 ' => 'Found ' ,
60
+ '303 ' => 'See Other ' ,
61
+ '304 ' => 'Not Modified ' ,
62
+ '305 ' => 'Use Proxy ' ,
63
+ '400 ' => 'Bad Request ' ,
64
+ '401 ' => 'Unauthorized ' ,
65
+ '402 ' => 'Payment Required ' ,
66
+ '403 ' => 'Forbidden ' ,
67
+ '404 ' => 'Not Found ' ,
68
+ '405 ' => 'Method Not Allowed ' ,
69
+ '406 ' => 'Not Acceptable ' ,
70
+ '407 ' => 'Proxy Authentication Required ' ,
71
+ '408 ' => 'Request Timeout ' ,
72
+ '409 ' => 'Conflict ' ,
73
+ '410 ' => 'Gone ' ,
74
+ '411 ' => 'Length Required ' ,
75
+ '412 ' => 'Precondition Failed ' ,
76
+ '413 ' => 'Request Entity Too Large ' ,
77
+ '414 ' => 'Request-URI Too Long ' ,
78
+ '415 ' => 'Unsupported Media Type ' ,
79
+ '416 ' => 'Requested Range Not Satisfiable ' ,
80
+ '417 ' => 'Expectation Failed ' ,
81
+ '500 ' => 'Internal Server Error ' ,
82
+ '501 ' => 'Not Implemented ' ,
83
+ '502 ' => 'Bad Gateway ' ,
84
+ '503 ' => 'Service Unavailable ' ,
85
+ '504 ' => 'Gateway Timeout ' ,
86
+ '505 ' => 'HTTP Version Not Supported '
87
+ ];
88
+ $ code = (string )$ code ;
89
+ if (array_key_exists ($ code , $ statuscodes )) {
90
+ return $ statuscodes [$ code ];
91
+ }
92
+ return $ code ;
93
+ }
39
94
}
0 commit comments