Skip to content

Commit

Permalink
Merge pull request #10 from tenantcloud/fix-null-value-enum-serializa…
Browse files Browse the repository at this point in the history
…tion

fix: Fixed enum serialization with null values.
KlebanAndrew authored Jun 15, 2022
2 parents cfa487a + e0d16ab commit aa5f81b
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
"ext-json": "*",
"illuminate/support": "^8.0 || ^9.0",
"spatie/macroable": "1.0.1",
"tenantcloud/php-standard": "^1.2"
"tenantcloud/php-standard": "1.2 || ^1.4"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
4 changes: 2 additions & 2 deletions src/TenantCloud/DataTransferObjects/IsDataTransferObject.php
Original file line number Diff line number Diff line change
@@ -94,11 +94,11 @@ public function __unserialize(array $data): void

if (is_iterable($serializedItem)) {
foreach ($serializedItem as $key => $item) {
Arr::set($dataItems[$index], $key, $enum::fromValue($item));
Arr::set($dataItems[$index], $key, $item === null ? $item : $enum::fromValue($item));
}
} else {
/* @var ValueEnum|null $enum */
Arr::set($dataItems, $index, $enum::fromValue($serializedItem));
Arr::set($dataItems, $index, $serializedItem === null ? $serializedItem : $enum::fromValue($serializedItem));
}
}
}

0 comments on commit aa5f81b

Please sign in to comment.