You are here

public static function Price::fromArray in Commerce Core 8.2

Creates a new price from the given array.

Parameters

array $price: The price array, with the "number" and "currency_code" keys.

Return value

static

12 calls to Price::fromArray()
AjaxPriceTestForm::submitForm in modules/price/tests/modules/commerce_price_test/src/Form/AjaxPriceTestForm.php
Form submission handler.
BuyXGetY::buildAdjustmentAmount in modules/promotion/src/Plugin/Commerce/PromotionOffer/BuyXGetY.php
Builds an adjustment amount for the given order item and quantity.
OrderTotalPrice::evaluate in modules/order/src/Plugin/Commerce/Condition/OrderTotalPrice.php
Evaluates the condition.
PaymentCaptureForm::submitConfigurationForm in modules/payment/src/PluginForm/PaymentCaptureForm.php
Form submission handler.
PaymentReceiveForm::submitConfigurationForm in modules/payment/src/PluginForm/PaymentReceiveForm.php
Form submission handler.

... See full list

File

modules/price/src/Price.php, line 52

Class

Price
Provides a value object for monetary values.

Namespace

Drupal\commerce_price

Code

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']);
}