You are here

public function PriceModified::convert in Price 8

Same name and namespace in other branches
  1. 3.x src/PriceModified.php \Drupal\price\PriceModified::convert()
  2. 3.0.x src/PriceModified.php \Drupal\price\PriceModified::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/PriceModified.php, line 113

Class

PriceModified
Provides a value object for monetary values.

Namespace

Drupal\price

Code

public function convert($currency_code, $rate = '1') {
  $new_number = Calculator::multiply($this->number, $rate);
  return new static($new_number, $currency_code, $this->modifier);
}