Money
Money class for your applications
Last updated
Money class for your applications
Last updated
use SaasReady\Helpers\Money;
$money = new Money(10_00, CurrencyCode::UNITED_STATES_DOLLAR); // $10.00
$money2 = Money::make(15_99, CurrencyCode::SINGAPORE_DOLLAR); // S$15.99
$money3 = Money::makeFromRealAmount(10.99, CurrencyCode::UNITED_STATE_DOLLAR); // $10.99$money = new Money(10_00, CurrencyCode::UNITED_STATES_DOLLAR); // $10.00
$otherMoney = $money->clone(); // $10.00
$otherMoneyButSameCurrency = $money->clone(1500_00); // $1500.00$money->add($otherMoney);
$money->subtract($otherMoney);
$money->multiply(2);
$money->divide(5);$money = new Money(10_00, CurrencyCode::UNITED_STATES_DOLLAR);
$money->present(); // $10.00 (uses symbol and decimals)
$money->present(false); // USD 10.00 (uses currency code and decimals)
$money->present(true, false); // $10 (uses symbol)
$money->present(false, false); // USD 10 (uses currency code)