Skip to content

Commit 23dd208

Browse files
Merge pull request #612 from rust17/main
Improve performance when optional peoperty exists
2 parents 7f81a7e + 1b34d17 commit 23dd208

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Transformers/DataTransformer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@ protected function resolvePayload(TransformableData $data): array
6969

7070
$payload = [];
7171

72+
$objVars = get_object_vars($data);
73+
7274
foreach ($dataClass->properties as $property) {
7375
if ($property->hidden) {
7476
continue;
7577
}
7678

7779
$name = $property->name;
7880

79-
if ($property->type->isOptional && ! array_key_exists($name, get_object_vars($data))) {
81+
if ($property->type->isOptional && ! array_key_exists($name, $objVars)) {
8082
continue;
8183
}
8284

0 commit comments

Comments
 (0)