Skip to content

Commit

Permalink
Merge pull request #40 from Piggy-Loyalty/39-uncaught-typeerror-get_o…
Browse files Browse the repository at this point in the history
…bject_vars

Fix mapping issue
  • Loading branch information
EdingerMike authored Oct 25, 2024
2 parents 4b5d343 + fa31367 commit 1ef237e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/StaticMappers/Vouchers/PromotionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ class PromotionMapper
{
public static function map($data): Promotion
{
if (is_array($data->attributes)) {
$attributes = $data->attributes;
} else {
$attributes = get_object_vars($data->attributes);
}

return new Promotion(
$data->uuid,
$data->name,
$data->description,
$data->voucher_limit ?? null,
$data->limit_per_contact ?? null,
$data->expiration_duration ?? null,
isset($data->attributes) ? get_object_vars($data->attributes) : []
isset($data->attributes) ? $attributes : []
);
}
}

0 comments on commit 1ef237e

Please sign in to comment.