@@ -341,46 +341,36 @@ public static function clearMessages()
341341
342342 private static function getMessageIndex (
343343 UnityHTTPDMessageLevel $ level ,
344- string $ title_regex ,
345- string $ body_regex ,
344+ string $ title ,
345+ string $ body ,
346346 ) {
347347 $ messages = self ::getMessages ();
348348 $ error_msg = sprintf (
349- "message(level='%s' title_regex ='%s' body_regex ='%s'), not found. found messages: %s " ,
349+ "message(level='%s' title ='%s' body ='%s'), not found. found messages: %s " ,
350350 $ level ->value ,
351- $ title_regex ,
352- $ body_regex ,
351+ $ title ,
352+ $ body ,
353353 jsonEncode ($ messages ),
354354 );
355355 foreach ($ messages as $ i => $ message ) {
356- if (
357- preg_match ($ title_regex , $ message [0 ]) &&
358- preg_match ($ body_regex , $ message [1 ]) &&
359- $ level == $ message [2 ]
360- ) {
356+ if ($ title == $ message [0 ] && $ body == $ message [1 ] && $ level == $ message [2 ]) {
361357 return $ i ;
362358 }
363359 }
364360 throw new UnityHTTPDMessageNotFoundException ($ error_msg );
365361 }
366362
367- /* returns the 1st message that matches criteria or throws UnityHTTPDMessageNotFoundException */
368- public static function getMessage (
369- UnityHTTPDMessageLevel $ level ,
370- string $ title_regex ,
371- string $ body_regex ,
372- ) {
373- $ index = self ::getMessageIndex ($ level , $ title_regex , $ body_regex );
363+ /* returns the 1st message that matches or throws UnityHTTPDMessageNotFoundException */
364+ public static function getMessage (UnityHTTPDMessageLevel $ level , string $ title , string $ body )
365+ {
366+ $ index = self ::getMessageIndex ($ level , $ title , $ body );
374367 return $ _SESSION ["messages " ][$ index ];
375368 }
376369
377- /* deletes the 1st message that matches criteria or throws UnityHTTPDMessageNotFoundException */
378- public static function deleteMessage (
379- UnityHTTPDMessageLevel $ level ,
380- string $ title_regex ,
381- string $ body_regex ,
382- ) {
383- $ index = self ::getMessageIndex ($ level , $ title_regex , $ body_regex );
370+ /* deletes the 1st message that matches or throws UnityHTTPDMessageNotFoundException */
371+ public static function deleteMessage (UnityHTTPDMessageLevel $ level , string $ title , string $ body )
372+ {
373+ $ index = self ::getMessageIndex ($ level , $ title , $ body );
384374 unset($ _SESSION ["messages " ][$ index ]);
385375 $ _SESSION ["messages " ] = array_values ($ _SESSION ["messages " ]);
386376 }
0 commit comments