for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* API for Billing
*
* @link https://github.com/hiqdev/billing-hiapi
* @package billing-hiapi
* @license BSD-3-Clause
* @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
*/
namespace hiqdev\billing\hiapi\vo;
use hiqdev\yii\DataMapper\hydrator\GeneratedHydrator;
use Money\Currency;
use Money\Money;
* Class MoneyHydrator.
* @author Andrii Vasyliev <[email protected]>
class MoneyHydrator extends GeneratedHydrator
{
public function hydrate(array $data, $object)
$currency = new Currency(strtoupper($data['currency']));
return new Money($data['amount'], $currency);
}
* {@inheritdoc}
* @param object|Money $object
public function extract($object)
return array_filter([
'currency' => $object->getCurrency(),
'amount' => $object->getAmount(),
]);