File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,21 @@ final class IdnaInfo
36
36
37
37
private int $ errors ;
38
38
39
+ /**
40
+ * @var array<int, string>
41
+ */
42
+ private array $ errorList ;
43
+
39
44
private function __construct (string $ result , bool $ isTransitionalDifferent , int $ errors )
40
45
{
41
46
$ this ->result = $ result ;
42
47
$ this ->errors = $ errors ;
43
48
$ this ->isTransitionalDifferent = $ isTransitionalDifferent ;
49
+ $ this ->errorList = array_filter (
50
+ self ::ERRORS ,
51
+ fn (int $ error ): bool => 0 !== ($ error & $ this ->errors ),
52
+ ARRAY_FILTER_USE_KEY
53
+ );
44
54
}
45
55
46
56
/**
@@ -76,18 +86,14 @@ public function errors(): int
76
86
77
87
public function error (int $ error ): ?string
78
88
{
79
- return 0 === ( $ this ->errors & $ error) ? null : self :: ERRORS [ $ error ] ;
89
+ return $ this ->errorList [ $ error] ?? null ;
80
90
}
81
91
82
92
/**
83
93
* @return array<int, string>
84
94
*/
85
95
public function errorList (): array
86
96
{
87
- return array_filter (
88
- self ::ERRORS ,
89
- fn (int $ errorByte ): bool => 0 !== ($ errorByte & $ this ->errors ),
90
- ARRAY_FILTER_USE_KEY
91
- );
97
+ return $ this ->errorList ;
92
98
}
93
99
}
You can’t perform that action at this time.
0 commit comments