public static function Calculator::add in Commerce Core 8.2
Adds the second number to the first number.
Parameters
string $first_number: The first number.
string $second_number: The second number.
int $scale: The maximum number of digits after the decimal place. Any digit after $scale will be truncated.
Return value
string The result.
7 calls to Calculator::add()
- BuyXGetY::calculateExpectedGetQuantity in modules/
promotion/ src/ Plugin/ Commerce/ PromotionOffer/ BuyXGetY.php - Calculates the expected get quantity.
- BuyXGetY::mergeQuantities in modules/
promotion/ src/ Plugin/ Commerce/ PromotionOffer/ BuyXGetY.php - Merges the first quantity list with the second quantity list.
- CalculatorTest::testArithmetic in modules/
price/ tests/ src/ Unit/ CalculatorTest.php - @covers ::add @covers ::subtract @covers ::multiply @covers ::divide @covers ::compare @covers ::trim
- CartManager::addOrderItem in modules/
cart/ src/ CartManager.php - Adds the given order item to the given cart order.
- OrderItemQuantity::evaluate in modules/
promotion/ src/ Plugin/ Commerce/ Condition/ OrderItemQuantity.php - Evaluates the condition.
File
- modules/
price/ src/ Calculator.php, line 30
Class
- Calculator
- Provides helpers for bcmath-based arithmetic.
Namespace
Drupal\commerce_priceCode
public static function add(string $first_number, string $second_number, int $scale = 6) : string {
self::assertNumberFormat($first_number);
self::assertNumberFormat($second_number);
$result = bcadd($first_number, $second_number, $scale);
return self::trim($result);
}