Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4cf7feb

Browse files
committed
[VarDumper] extract error dumping in dedicated method
1 parent 9f4c594 commit 4cf7feb

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/Symfony/Component/VarDumper/Caster/IntlCaster.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
/**
1717
* @author Nicolas Grekas <[email protected]>
18+
* @author Jan Schädlich <[email protected]>
1819
*/
1920
class IntlCaster
2021
{
@@ -25,14 +26,7 @@ public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub
2526
Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(),
2627
);
2728

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);
3630
}
3731

3832
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 $
4539
if ($filter & Caster::EXCLUDE_VERBOSE) {
4640
$stub->cut += 3;
4741

48-
return $a;
42+
return self::dumpError($c, $a);
4943
}
5044

5145
$a += array(
@@ -109,6 +103,11 @@ public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $
109103
),
110104
);
111105

106+
return self::dumpError($c, $a);
107+
}
108+
109+
private static function dumpError($c, array $a): array
110+
{
112111
if ($errorCode = $c->getErrorCode()) {
113112
$a += array(
114113
Caster::PREFIX_VIRTUAL.'error_code' => $errorCode,

0 commit comments

Comments
 (0)