Money Complex Value Object
September 7, 2020 · View on GitHub
Do you like this library? Leave a ★ or run composer global require symfony/thanks && composer thanks to say thank you to all libraries you use in your current project, this included!
Money Complex Value Object
Represents a monetary value.
Extends moneyphp/money.
- How to use the Doctrine's type
money - How to use the Twig extensions
- How to use the Symfony Form type
Base Money signature
// vendor/moneyphp/money/src/Money.php
/**
* @param integer $amount
* @param \Money\Currency|string $currency
* @throws \Money\InvalidArgumentException
*/
public function __construct($amount, $currency)
How to use the object
See the working example: examples/Currency.php.
use SerendipityHQ\Component\ValueObjects\Money\Money;
$values = [
Money::HUMAN_AMOUNT => 300,
Money::CURRENCY => 'EUR'
];
$money = new Money($values);
dump($money);
NOTES
This object is a wrapper for the Money object by PHPMoney.
As the original object is a final class, it is not possible to extend it.
So this ValueObjects\Money object simply wraps an \Money\Money object.
Do you like this library? Leave a ★ or run composer global require symfony/thanks && composer thanks to say thank you to all libraries you use in your current project, this included!