66use UnityWebPortal \lib \exceptions \ArrayKeyException ;
77use RuntimeException ;
88
9- enum UnityHTTPDMessageSeverity : string
9+ enum UnityHTTPDMessageLevel : string
1010{
11+ case DEBUG = "debug " ;
1112 case INFO = "info " ;
12- case GOOD = "good " ;
13- case BAD = "bad " ;
13+ case SUCCESS = "success " ;
14+ case WARNING = "warning " ;
15+ case ERROR = "error " ;
1416}
1517
1618class UnityHTTPD
@@ -206,22 +208,30 @@ public static function alert(string $message): void
206208 echo "<script type='text/javascript'>alert( " . \jsonEncode ($ message ) . ");</script> " ;
207209 }
208210
209- public static function message (string $ title , string $ body , UnityHTTPDMessageSeverity $ severity )
211+ public static function message (string $ title , string $ body , UnityHTTPDMessageLevel $ level )
210212 {
211- array_push ($ _SESSION ["messages " ], [$ title , $ body , $ severity ]);
213+ array_push ($ _SESSION ["messages " ], [$ title , $ body , $ level ]);
212214 }
213215
214- public static function messageGood (string $ title , string $ body )
216+ public static function messageDebug (string $ title , string $ body )
215217 {
216- return self ::message ($ title , $ body , UnityHTTPDMessageSeverity:: GOOD );
218+ return self ::message ($ title , $ body , UnityHTTPDMessageLevel:: DEBUG );
217219 }
218- public static function messageBad (string $ title , string $ body )
220+ public static function messageInfo (string $ title , string $ body )
219221 {
220- return self ::message ($ title , $ body , UnityHTTPDMessageSeverity:: BAD );
222+ return self ::message ($ title , $ body , UnityHTTPDMessageLevel:: INFO );
221223 }
222- public static function messageInfo (string $ title , string $ body )
224+ public static function messageSuccess (string $ title , string $ body )
225+ {
226+ return self ::message ($ title , $ body , UnityHTTPDMessageLevel::SUCCESS );
227+ }
228+ public static function messageWarning (string $ title , string $ body )
229+ {
230+ return self ::message ($ title , $ body , UnityHTTPDMessageLevel::WARNING );
231+ }
232+ public static function messageError (string $ title , string $ body )
223233 {
224- return self ::message ($ title , $ body , UnityHTTPDMessageSeverity:: INFO );
234+ return self ::message ($ title , $ body , UnityHTTPDMessageLevel:: ERROR );
225235 }
226236
227237 public static function getMessages ()
@@ -248,11 +258,11 @@ public static function clearMessages()
248258 public static function exportMessagesHTML ()
249259 {
250260 $ output = "" ;
251- foreach (self ::getMessages () as [$ title , $ body , $ severity ]) {
261+ foreach (self ::getMessages () as [$ title , $ body , $ level ]) {
252262 $ title_stripped = strip_tags ($ title );
253263 $ body_stripped = strip_tags ($ body );
254- $ severity_str = $ severity ->value ;
255- $ output .= "<div class='message $ severity_str '><h2> $ title_stripped</h2><p> $ body_stripped</p></div> \n" ;
264+ $ level_str = $ level ->value ;
265+ $ output .= "<div class='message $ level_str '><h2> $ title_stripped</h2><p> $ body_stripped</p></div> \n" ;
256266 }
257267 return $ output ;
258268 }
0 commit comments