File tree Expand file tree Collapse file tree 2 files changed +10
-14
lines changed
Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Original file line number Diff line number Diff line change 4444 "laminas/laminas-psr7bridge" : " ^1.8" ,
4545 "laminas/laminas-uri" : " ^2.10" ,
4646 "psr/container" : " ^1.1.2 || 2.0" ,
47+ "samsonasik/array-lookup" : " ^1.0" ,
4748 "seld/jsonlint" : " ^1.9" ,
4849 "webmozart/assert" : " ^1.11"
4950 },
Original file line number Diff line number Diff line change 44
55namespace ErrorHeroModule ;
66
7+ use ArrayLookup \AtLeast ;
78use Seld \JsonLint \JsonParser ;
89use Throwable ;
910
@@ -24,23 +25,17 @@ function detectMessageContentType(string $message): string
2425function isExcludedException (array $ excludeExceptionsConfig , Throwable $ throwable ): bool
2526{
2627 $ exceptionOrErrorClass = $ throwable ::class;
28+ $ message = $ throwable ->getMessage ();
2729
28- $ isExcluded = false ;
29- foreach ($ excludeExceptionsConfig as $ excludeExceptionConfig ) {
30- if ($ exceptionOrErrorClass === $ excludeExceptionConfig ) {
31- $ isExcluded = true ;
32- break ;
30+ $ filter = static function (string |array $ excludeExceptionConfig ) use ($ exceptionOrErrorClass , $ message ): bool {
31+ if ($ excludeExceptionConfig === $ exceptionOrErrorClass ) {
32+ return true ;
3333 }
3434
35- if (
36- is_array ($ excludeExceptionConfig )
35+ return is_array ($ excludeExceptionConfig )
3736 && $ excludeExceptionConfig [0 ] === $ exceptionOrErrorClass
38- && $ excludeExceptionConfig [1 ] === $ throwable ->getMessage ()
39- ) {
40- $ isExcluded = true ;
41- break ;
42- }
43- }
37+ && $ excludeExceptionConfig [1 ] === $ message ;
38+ };
4439
45- return $ isExcluded ;
40+ return AtLeast:: once ( $ excludeExceptionsConfig , $ filter ) ;
4641}
You can’t perform that action at this time.
0 commit comments