File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed
Expand file tree Collapse file tree 2 files changed +14
-15
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,20 @@ function detectMessageContentType(string $message): string
2425function isExcludedException (array $ excludeExceptionsConfig , Throwable $ throwable ): bool
2526{
2627 $ exceptionOrErrorClass = $ throwable ::class;
27-
28- $ isExcluded = false ;
29- foreach ($ excludeExceptionsConfig as $ excludeExceptionConfig ) {
30- if ($ exceptionOrErrorClass === $ excludeExceptionConfig ) {
31- $ isExcluded = true ;
32- break ;
28+ $ message = $ throwable ->getMessage ();
29+
30+ /**
31+ * @param string|array<int, string> $excludeExceptionConfig
32+ */
33+ $ filter = static function (mixed $ excludeExceptionConfig ) use ($ exceptionOrErrorClass , $ message ): bool {
34+ if ($ excludeExceptionConfig === $ exceptionOrErrorClass ) {
35+ return true ;
3336 }
3437
35- if (
36- is_array ($ excludeExceptionConfig )
38+ return is_array ($ excludeExceptionConfig )
3739 && $ excludeExceptionConfig [0 ] === $ exceptionOrErrorClass
38- && $ excludeExceptionConfig [1 ] === $ throwable ->getMessage ()
39- ) {
40- $ isExcluded = true ;
41- break ;
42- }
43- }
40+ && $ excludeExceptionConfig [1 ] === $ message ;
41+ };
4442
45- return $ isExcluded ;
43+ return AtLeast:: once ( $ excludeExceptionsConfig , $ filter ) ;
4644}
You can’t perform that action at this time.
0 commit comments