class Currency in Currency 7.2
Same name in this branch
- 7.2 currency/includes/Currency.inc \Currency
- 7.2 currency/vendor/bartfeenstra/currency/src/BartFeenstra/Currency/Currency.php \BartFeenstra\Currency\Currency
Describes a currency.
Hierarchy
Expanded class hierarchy of Currency
26 string references to 'Currency'
- currency.inc in currency/
ctools/ plugins/ export_ui/ currency.inc - CurrencyAmountFormElementWebTestCase::getInfo in currency/
tests/ CurrencyAmountFormElementWebTestCase.test - Implements DrupalTestCase::getInfo().
- CurrencyAmountViewsHandlerFieldWebTestCase::getInfo in currency/
tests/ CurrencyAmountViewsHandlerFieldWebTestCase.test - Implements DrupalTestCase::getInfo().
- CurrencyCRUDWebTestCase::getInfo in currency/
tests/ CurrencyCRUDWebTestCase.test - Implements DrupalTestCase::getInfo().
- CurrencyExchangerBartFeenstraCurrencyWebTestCase::getInfo in currency/
tests/ CurrencyConverterBartFeenstraCurrencyWebTestCase.test - Implements DrupalTestCase::getInfo().
File
- currency/
includes/ Currency.inc, line 11 - Contains class Currency.
View source
class Currency extends BartFeenstra\Currency\Currency {
/**
* Implements Ctools' exportables "export_module" property.
*
* @var string
*/
public $export_module = 'currency';
/**
* Implements Ctools' exportables "export_type" property.
*
* @var string
*/
public $export_type = 0;
/**
* The number of subunits to round amounts in this currency to.
*
* @see Currency::getRoundingStep()
*
* @var integer
*/
public $rounding_step = NULL;
/**
* Implements Ctools' exportables "table" property.
*
* @var string
*/
public $table = 'currency';
/**
* Implements Ctools' exportables "type" property.
*
* @var string
*/
public $type = 'Local';
/**
* Implements __construct().
*/
function __construct(array $properties = array()) {
foreach ($properties as $property => $value) {
$this->{$property} = $value;
}
}
/**
* Format an amount using this currency and the environment's default locale
* pattern.
*
* This is a wrapper for CurrencyLocalePattern::format() in situations where
* the environment's default locale pattern should be used.
*
* @param string $amount
* A numeric string.
*
* @return string
*/
function format($amount) {
return CurrencyLocalePattern::loadFromEnv()
->format($this, $amount);
}
/**
* Returns the rounding step.
*
* @return string|false
* The rounding step as a numeric string, or FALSE if unavailable.
*/
function getRoundingStep() {
if (is_numeric($this->rounding_step)) {
return $this->rounding_step;
}
elseif (is_numeric($this->subunits)) {
return $this->subunits > 0 ? currency_divide(1, $this->subunits) : 1;
}
else {
return FALSE;
}
}
/**
* Rounds an amount.
*
* @param string $amount
* A numeric string.
*
* @return string
* A numeric string.
*/
function roundAmount($amount) {
return currency_round($amount, $this
->getRoundingStep());
}
/**
* Translates the human-readable currency title.
*
* @param string|null $language_code
* The ISO 639-1 code of the language to translate the title to, or NULL to
* use the default language.
*
* @return string
*/
function translateTitle($language_code = NULL) {
if (module_exists('i18n_string')) {
return i18n_string('currency:currency:' . $this->ISO4217Code . ':title', $this->title, array(
'langcode' => $language_code,
));
}
return $this->title;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Currency:: |
public | property | Alternative (non-official) currency signs. | |
Currency:: |
public | property | Exchange rates to other currencies. | |
Currency:: |
public | property | Implements Ctools' exportables "export_module" property. | |
Currency:: |
public | property | Implements Ctools' exportables "export_type" property. | |
Currency:: |
public | property | ISO 4217 currency code. | |
Currency:: |
public | property | ISO 4217 currency number. | |
Currency:: |
public static | property | A list of the ISO 4217 codes of all known currency resources. | |
Currency:: |
public static | property | The path to the resources directory. | |
Currency:: |
public | property | The number of subunits to round amounts in this currency to. | |
Currency:: |
public | property | The currency's official sign, such as '€' or '$'. | |
Currency:: |
public | property | The number of subunits this currency has. | |
Currency:: |
public | property | Implements Ctools' exportables "table" property. | |
Currency:: |
public | property | Human-readable title in US English. | |
Currency:: |
public | property | Implements Ctools' exportables "type" property. | |
Currency:: |
public | property | This currency's usage. | |
Currency:: |
function | Format an amount using this currency and the environment's default locale pattern. | ||
Currency:: |
function | Returns the number of decimals. | ||
Currency:: |
function | Returns the rounding step. | ||
Currency:: |
public static | function | Returns the directory that contains the currency resources. | |
Currency:: |
public | function | Dumps this object to YAML code. | |
Currency:: |
public static | function | Lists all currency resources in the library. | |
Currency:: |
public | function | Loads a currency resource into this object. | |
Currency:: |
public | function | Parses a YAML file into this object. | |
Currency:: |
function | Rounds an amount. | ||
Currency:: |
function | Translates the human-readable currency title. | ||
Currency:: |
function | Implements __construct(). |