Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
AmountFactory.php
Go to the documentation of this file.
1 <?php
8 
16 {
20  const DEFAULT_PRICE_AMOUNT_CLASS = \Magento\Framework\Pricing\Amount\AmountInterface::class;
21 
25  protected $objectManager;
26 
33  {
34  $this->objectManager = $objectManager;
35  }
36 
45  public function create($amount, array $adjustmentAmounts = [])
46  {
47  $amountModel = $this->objectManager->create(
48  self::DEFAULT_PRICE_AMOUNT_CLASS,
49  [
50  'amount' => $amount,
51  'adjustmentAmounts' => $adjustmentAmounts
52  ]
53  );
54 
55  if (!$amountModel instanceof \Magento\Framework\Pricing\Amount\AmountInterface) {
56  throw new \InvalidArgumentException(
57  get_class($amountModel) . ' doesn\'t implement \Magento\Framework\Pricing\Amount\AmountInterface'
58  );
59  }
60 
61  return $amountModel;
62  }
63 }
__construct(\Magento\Framework\ObjectManagerInterface $objectManager)
$amount
Definition: order.php:14
create($amount, array $adjustmentAmounts=[])