Skip to content

Commit

Permalink
Added support for denormalizing currency
Browse files Browse the repository at this point in the history
Signed-off-by: RJ Garcia <rj@bighead.net>
  • Loading branch information
ragboyjr committed Nov 6, 2018
1 parent 10d3114 commit 4e66742
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/MoneyDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
class MoneyDenormalizer implements DenormalizerInterface
{
public function denormalize($data, $class, $format = null, array $context = array()) {
return new Money($data['amount'], new Currency($data['currency']));
if ($class === Money::class) {
return new Money($data['amount'], new Currency($data['currency']));
} else {
return new Currency($data);
}
}

public function supportsDenormalization($data, $type, $format = null) {
return $type === Money::class;
return $type === Money::class || $type === Currency::class;
}
}

0 comments on commit 4e66742

Please sign in to comment.