1
0
Fork 0
mirror of https://github.com/archtechx/money.git synced 2025-12-12 11:24:03 +00:00

Add function_exists() checks

This commit is contained in:
Samuel Štancl 2021-11-16 19:47:37 +01:00
parent 739f8f8af0
commit efe697b051

View file

@ -6,12 +6,15 @@ use ArchTech\Money\Currency;
use ArchTech\Money\CurrencyManager; use ArchTech\Money\CurrencyManager;
use ArchTech\Money\Money; use ArchTech\Money\Money;
if (! function_exists('money')) {
/** Create a Money instance. */ /** Create a Money instance. */
function money(int $amount, Currency|string $currency = null): Money function money(int $amount, Currency|string $currency = null): Money
{ {
return new Money($amount, $currency ?? currencies()->getDefault()); return new Money($amount, $currency ?? currencies()->getDefault());
} }
}
if (! function_exists('currency')) {
/** Fetch a currency. If no argument is provided, the current currency will be returned. */ /** Fetch a currency. If no argument is provided, the current currency will be returned. */
function currency(Currency|string $currency = null): Currency function currency(Currency|string $currency = null): Currency
{ {
@ -23,9 +26,12 @@ function currency(Currency|string $currency = null): Currency
return currencies()->getCurrent(); return currencies()->getCurrent();
} }
}
if (! function_exists('currencies')) {
/** Get the CurrencyManager instance. */ /** Get the CurrencyManager instance. */
function currencies(): CurrencyManager function currencies(): CurrencyManager
{ {
return app(CurrencyManager::class); return app(CurrencyManager::class);
} }
}