CurrencyRepository
Manages currencies based on JSON definitions.
- Full name:
\CommerceGuys\Intl\Currency\CurrencyRepository
- This class implements:
\CommerceGuys\Intl\Currency\CurrencyRepositoryInterface
Properties
defaultLocale
The default locale.
fallbackLocale
The fallback locale.
definitionPath
The path where per-locale definitions are stored.
definitions
Per-locale currency definitions.
availableLocales
The available locales.
Methods
__construct
Creates a CurrencyRepository instance.
public __construct(string $defaultLocale = 'en', string $fallbackLocale = 'en', string $definitionPath = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$defaultLocale |
string | The default locale. Defaults to 'en'. |
$fallbackLocale |
string | The fallback locale. Defaults to 'en'. |
$definitionPath |
string | The path to the currency definitions. Defaults to 'resources/currency'. |
get
Gets a currency matching the provided currency code.
Parameters:
Parameter | Type | Description |
---|---|---|
$currencyCode |
mixed | The currency code. |
$locale |
mixed | The locale (i.e. fr-FR). |
getAll
Gets all currencies.
Parameters:
Parameter | Type | Description |
---|---|---|
$locale |
mixed | The locale (i.e. fr-FR). |
Return Value:
An array of currencies, keyed by currency code.
getList
Gets a list of currencies.
Parameters:
Parameter | Type | Description |
---|---|---|
$locale |
mixed | The locale (i.e. fr-FR). |
Return Value:
An array of currency names, keyed by currency code.
loadDefinitions
Loads the currency definitions for the provided locale.
Parameters:
Parameter | Type | Description |
---|---|---|
$locale |
string | The desired locale. |
getBaseDefinitions
Gets the base currency definitions.
Contains data common to all locales: numeric code, fraction digits.
Return Value:
An array of definitions, keyed by currency code. Each definition is a numerically indexed array containing: - The numeric code. - The fraction digits.
Automatically generated on 2025-03-18