class Currency

Properties

protected array $config

Currency configuration.

protected Factory $cache

Application cache

protected CurrencyInterface $model

Currency model instance.

protected FormatterInterface $formatter

Formatter instance.

protected string $userCurrency

User's currency

protected Collection $currenciesCache

Cached currencies

protected Collection $loadedCurrencies

Loaded currencies

Methods

__construct(array $config, Factory $cache)

Create a new instance.

string
convert(float $amount, string $from = null, string $to = null, bool $format = true)

Format given number.

string
format(float $value, string $code = null, bool $includeSymbol = true)

Format the value into the desired currency.

string
formatToJson(float $value, string $code = null)

Format the value into a json array

setUserCurrency(string $code)

Set user's currency.

string
getUserCurrency()

Return the user's currency code.

bool
hasCurrency(string $code)

Determine if the provided currency is valid.

bool
isActive(string $code)

Determine if the provided currency is active.

getCurrency(string $code = null)

Return the current currency if the one supplied is not valid.

Collection
getCurrencies()

Return all currencies.

getModel()

Get currency model.

getFormatter()

Get formatter driver.

clearCache()

Clear cached currencies.

mixed
config(string $key = null, mixed $default = null)

Get configuration value.

loadCurrencies()

No description

updateRates($skipCache = false)

No description

getRates($base, $skipCache = false)

No description

mixed
__get(string $key)

Get a given value from the current currency.

mixed
__call(string $method, array $parameters)

Dynamically call the default driver instance.

Details

at line 67
__construct(array $config, Factory $cache)

Create a new instance.

Parameters

array $config
Factory $cache

at line 83
string convert(float $amount, string $from = null, string $to = null, bool $format = true)

Format given number.

Parameters

float $amount
string $from
string $to
bool $format

Return Value

string

at line 122
string format(float $value, string $code = null, bool $includeSymbol = true)

Format the value into the desired currency.

Parameters

float $value
string $code
bool $includeSymbol

Return Value

string

at line 186
string formatToJson(float $value, string $code = null)

Format the value into a json array

Parameters

float $value
string $code

Return Value

string

at line 205
setUserCurrency(string $code)

Set user's currency.

Parameters

string $code

at line 215
string getUserCurrency()

Return the user's currency code.

Return Value

string

at line 229
bool hasCurrency(string $code)

Determine if the provided currency is valid.

Parameters

string $code

Return Value

bool

at line 241
bool isActive(string $code)

Determine if the provided currency is active.

Parameters

string $code

Return Value

bool

at line 254
CurrencyInterface getCurrency(string $code = null)

Return the current currency if the one supplied is not valid.

Parameters

string $code

Return Value

CurrencyInterface

at line 274
Collection getCurrencies()

Return all currencies.

Return Value

Collection

at line 288
CurrencyInterface|Model getModel()

Get currency model.

Return Value

CurrencyInterface|Model

at line 306
FormatterInterface getFormatter()

Get formatter driver.

Return Value

FormatterInterface

at line 325
clearCache()

Clear cached currencies.

at line 338
mixed config(string $key = null, mixed $default = null)

Get configuration value.

Parameters

string $key
mixed $default

Return Value

mixed

at line 347
protected loadCurrencies()

No description

at line 360
updateRates($skipCache = false)

No description

Parameters

$skipCache

at line 372
protected getRates($base, $skipCache = false)

No description

Parameters

$base
$skipCache

at line 393
mixed __get(string $key)

Get a given value from the current currency.

Parameters

string $key

Return Value

mixed

at line 406
mixed __call(string $method, array $parameters)

Dynamically call the default driver instance.

Parameters

string $method
array $parameters

Return Value

mixed