Skip to content
Last updated

WHMCS\Billing\Currency

Class · extends AbstractModel · implements CurrencyInterface

A currency.

Constants

NameDescription
DEFAULT_CURRENCY_ID

Properties

TypeNameDescription
``$timestamps

Methods

boot

public static function boot()

scopeDefaultCurrency

public function scopeDefaultCurrency($query)

scopeCode

public function scopeCode(Builder $query, string $code): Builder

scopeDefaultSorting

public function scopeDefaultSorting($query)

Show default currency first, and all other currencies sorted by currency code.

Parameters

TypeNameDescription
Builder$query

Returns Builder

validateCurrencyCode

public static function validateCurrencyCode($currencyCode)

factoryForClientArea

public static function factoryForClientArea()

convertTo

public function convertTo(float $amount, Currency $currency): float

convertBetween

public static function convertBetween(CurrencyInterface $fromCurrency, float $amount, CurrencyInterface $toCurrency): float

Convert amount between currencies

Parameters

TypeNameDescription
CurrencyInterface$fromCurrency
float$amount
CurrencyInterface$toCurrency

Returns float

getCode

public function getCode(): string

setCode

public function setCode(string $code): self

getRate

public function getRate(): float

setRate

public function setRate(float $rate): self

nonFractionalCurrencyCodes

public function nonFractionalCurrencyCodes(): array

Returns string[]

isNonFractionalCurrency

public function isNonFractionalCurrency(): bool

valueInCurrencyPrecision

public function valueInCurrencyPrecision(float $amount): float

Yield a value that reflects the Currency's support for fractional amounts. This makes no attempt to return a value that match the actual fractional precision for fraction supporting Currency. For example in the Currency is USD, and 1.666 is provided, 1.666 is returned. If the Currency is JPY for that same amount, 2.00 will be returned.

Note, even if this is a non-fractional currency, a float is returned for consistency.

Parameters

TypeNameDescription
float$amount

Returns float