You are here

interface MinorUnitsConverterInterface in Commerce Core 8.2

Allows converting between Price objects (decimal) and minor units (integer).

Hierarchy

Expanded class hierarchy of MinorUnitsConverterInterface

All classes that implement MinorUnitsConverterInterface

4 files declare their use of MinorUnitsConverterInterface
Manual.php in modules/payment/src/Plugin/Commerce/PaymentGateway/Manual.php
Onsite.php in modules/payment_example/src/Plugin/Commerce/PaymentGateway/Onsite.php
PaymentGatewayBase.php in modules/payment/src/Plugin/Commerce/PaymentGateway/PaymentGatewayBase.php
StoredOffsiteRedirect.php in modules/payment_example/src/Plugin/Commerce/PaymentGateway/StoredOffsiteRedirect.php

File

modules/price/src/MinorUnitsConverterInterface.php, line 8

Namespace

Drupal\commerce_price
View source
interface MinorUnitsConverterInterface {

  /**
   * Converts an amount in "minor unit" to a decimal amount.
   *
   * For example, 999 USD becomes 9.99.
   *
   * @param int|string $amount
   *   The amount in minor unit.
   * @param string $currency_code
   *   The currency code.
   *
   * @return \Drupal\commerce_price\Price
   *   The decimal price.
   */
  public function fromMinorUnits($amount, $currency_code) : Price;

  /**
   * Converts the given amount to its minor units.
   *
   * For example, 9.99 USD becomes 999.
   *
   * @param \Drupal\commerce_price\Price $amount
   *   The amount.
   *
   * @return int
   *   The amount in minor units, as an integer.
   */
  public function toMinorUnits(Price $amount) : int;

}

Members

Namesort descending Modifiers Type Description Overrides
MinorUnitsConverterInterface::fromMinorUnits public function Converts an amount in "minor unit" to a decimal amount. 1
MinorUnitsConverterInterface::toMinorUnits public function Converts the given amount to its minor units. 1