15
15
16
16
/**
17
17
* @author Nicolas Grekas <[email protected] >
18
+ * @author Jan Schädlich <[email protected] >
18
19
*/
19
20
class IntlCaster
20
21
{
@@ -25,14 +26,7 @@ public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub
25
26
Caster::PREFIX_VIRTUAL .'pattern ' => $ c ->getPattern (),
26
27
);
27
28
28
- if ($ errorCode = $ c ->getErrorCode ()) {
29
- $ a += array (
30
- Caster::PREFIX_VIRTUAL .'error_code ' => $ errorCode ,
31
- Caster::PREFIX_VIRTUAL .'error_message ' => $ c ->getErrorMessage (),
32
- );
33
- }
34
-
35
- return $ a ;
29
+ return self ::dumpError ($ c , $ a );
36
30
}
37
31
38
32
public static function castNumberFormatter (\NumberFormatter $ c , array $ a , Stub $ stub , $ isNested , $ filter = 0 )
@@ -45,7 +39,7 @@ public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $
45
39
if ($ filter & Caster::EXCLUDE_VERBOSE ) {
46
40
$ stub ->cut += 3 ;
47
41
48
- return $ a ;
42
+ return self :: dumpError ( $ c , $ a ) ;
49
43
}
50
44
51
45
$ a += array (
@@ -109,6 +103,11 @@ public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $
109
103
),
110
104
);
111
105
106
+ return self ::dumpError ($ c , $ a );
107
+ }
108
+
109
+ private static function dumpError ($ c , array $ a ): array
110
+ {
112
111
if ($ errorCode = $ c ->getErrorCode ()) {
113
112
$ a += array (
114
113
Caster::PREFIX_VIRTUAL .'error_code ' => $ errorCode ,
0 commit comments