Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Calculator Class Reference

Public Member Functions

 __construct (\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency)
 
 deltaRound ($price, $negative=false)
 

Protected Attributes

 $_delta = 0.0
 
 $priceCurrency
 

Detailed Description

Calculations Library

@api

Since
100.0.2

Definition at line 14 of file Calculator.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Pricing\PriceCurrencyInterface  $priceCurrency)
Parameters
\Magento\Framework\Pricing\PriceCurrencyInterface$priceCurrency

Definition at line 31 of file Calculator.php.

32  {
33  $this->priceCurrency = $priceCurrency;
34  }

Member Function Documentation

◆ deltaRound()

deltaRound (   $price,
  $negative = false 
)

Round price considering delta

Parameters
float$price
bool$negativeIndicates if we perform addition (true) or subtraction (false) of rounded value
Returns
float

Definition at line 43 of file Calculator.php.

44  {
45  $roundedPrice = $price;
46  if ($roundedPrice) {
47  if ($negative) {
48  $this->_delta = -$this->_delta;
49  }
51  $roundedPrice = $this->priceCurrency->round($price);
52  $this->_delta = $price - $roundedPrice;
53  if ($negative) {
54  $this->_delta = -$this->_delta;
55  }
56  }
57  return $roundedPrice;
58  }
$price

Field Documentation

◆ $_delta

$_delta = 0.0
protected

Definition at line 21 of file Calculator.php.

◆ $priceCurrency

$priceCurrency
protected

Definition at line 26 of file Calculator.php.


The documentation for this class was generated from the following file: