public static function Price::fromArray in Price 2.x
Same name and namespace in other branches
- 2.0.x src/Price.php \Drupal\price\Price::fromArray()
Creates a new price from the given array.
Parameters
array $price: The price array, with the "number" and "currency_code" keys.
Return value
static
File
- src/
Price.php, line 52
Class
- Price
- Provides a value object for monetary values.
Namespace
Drupal\priceCode
public static function fromArray(array $price) : Price {
if (!isset($price['number'], $price['currency_code'])) {
throw new \InvalidArgumentException('Price::fromArray() called with a malformed array.');
}
return new static($price['number'], $price['currency_code']);
}