Skip to content

Commit

Permalink
Add isset() condition to coerce.
Browse files Browse the repository at this point in the history
  • Loading branch information
david_smith committed Oct 14, 2024
1 parent 300c4c9 commit 4bd1335
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/DataModelHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ trait DataModelHelper
public static function mapOf(mixed $value, array $context, ?ReflectionAttribute $Attribute, ReflectionProperty $Property)
{
$args = $Attribute?->getArguments();
$value = isset($args[0]['coerce']) ? [$value] : $value;
$value = isset($args[0]['coerce']) && !isset($value[0]) ? [$value] : $value;

if (isset($Attribute?->getArguments()[0]['using'])) {
return ($Attribute?->getArguments()[0]['using'])($value);
Expand Down

0 comments on commit 4bd1335

Please sign in to comment.