8000 [VarDumper] extract error dumping in dedicated method · symfony/symfony@b34fe65 · GitHub
[go: up one dir, main page]

Skip to content

Commit b34fe65

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

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

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

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

1616
/**
1717
* @author Nicolas Grekas <p@tchwork.com>
18+
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
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,10 +103,15 @@ 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(
114-
Caster::PREFIX_VIRTUAL.'error_code' => $errorCode,
115-
Caster::PREFIX_VIRTUAL.'error_message' => $c->getErrorMessage(),
113+
Caster::PREFIX_VIRTUAL . 'error_code' => $errorCode,
114+
Caster::PREFIX_VIRTUAL . 'error_message' => $c->getErrorMessage(),
116115
);
117116
}
118117

0 commit comments

Comments
 (0)
0