public function Price::convert in Price 8
Same name and namespace in other branches
- 3.x src/Price.php \Drupal\price\Price::convert()
- 2.0.x src/Price.php \Drupal\price\Price::convert()
- 2.x src/Price.php \Drupal\price\Price::convert()
- 3.0.x src/Price.php \Drupal\price\Price::convert()
Converts the current price to the given currency.
Parameters
string $currency_code: The currency code.
string $rate: A currency rate corresponding to the currency code.
Return value
static The resulting price.
File
- src/
Price.php, line 95
Class
- Price
- Provides a value object for monetary values.
Namespace
Drupal\priceCode
public function convert($currency_code, $rate = '1') {
$new_number = Calculator::multiply($this->number, $rate);
return new static($new_number, $currency_code);
}