We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 95f3b55 commit 009f218Copy full SHA for 009f218
src/Transformers/EnumTransformer.php
@@ -73,6 +73,22 @@ protected function toEnumValue(ReflectionEnumBackedCase $case): string
73
{
74
$value = $case->getBackingValue();
75
76
- return is_string($value) ? "'" . str_replace('\\', '\\\\', $value) . "'" : "{$value}";
+ $newValue = "";
77
+
78
+ if (!is_string($value)) {
79
+ return "{$value}";
80
+ }
81
82
+ for ($i = 0; $i < strlen($value); $i++) {
83
+ $char = $value[$i];
84
85
+ match ($char) {
86
+ '\\' => $newValue .= '\\\\',
87
+ '\'' => $newValue .= '\\\'',
88
+ default => $newValue .= $char,
89
+ };
90
91
92
+ return "'" . $newValue . "'";
93
}
94
0 commit comments