You are here

public function Price::__construct in Price 3.0.x

Same name and namespace in other branches
  1. 8 src/Price.php \Drupal\price\Price::__construct()
  2. 3.x src/Price.php \Drupal\price\Price::__construct()
  3. 2.0.x src/Price.php \Drupal\price\Price::__construct()
  4. 2.x src/Price.php \Drupal\price\Price::__construct()

Constructs a new Price object.

Parameters

string $number: The number.

string $currency_code: The currency code.

File

src/Price.php, line 36

Class

Price
Provides a value object for monetary values.

Namespace

Drupal\price

Code

public function __construct($number, $currency_code) {
  Calculator::assertNumberFormat($number);
  $this
    ->assertCurrencyCodeFormat($currency_code);
  $this->number = (string) $number;
  $this->currencyCode = strtoupper($currency_code);
}