Skip to content

Commit

Permalink
refactor(dto): remove model union type first due concerns on compatib…
Browse files Browse the repository at this point in the history
…le across version
  • Loading branch information
kevariable committed Mar 29, 2023
1 parent f09af8b commit 13fac95
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Foundation/DataTransferObject/HasResolvable.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected static function resolveArrayKeyOfInput(string $key): string
}

/**
* @param array<TKey, TValue> | Model $data
* @param array<TKey, TValue> $data
*
* Hydrate incoming data to resolve unstructured data
*
Expand All @@ -139,18 +139,15 @@ protected static function resolveArrayKeyOfInput(string $key): string
* @template TKey of array-key
* @template TValue
*/
public static function hydrate(array | Model $data): static
public static function hydrate(array $data): static
{
/** @var DataMapper $dataMapper */
$dataMapper = resolve(name: DataMapper::class);

/** @var static $instance */
$instance = $dataMapper->execute(
signature: static::class,
data: match (true) {
$data instanceof Model => $data->attributesToArray(),
default => $data
}
data: $data
);

return $instance;
Expand Down

0 comments on commit 13fac95

Please sign in to comment.