public static function Calculator::assertNumberFormat in Commerce Core 8.2
Assert that the given number is a numeric string value.
Parameters
string $number: The number to check.
Throws
\InvalidArgumentException Thrown when the given number is not a numeric string value.
7 calls to Calculator::assertNumberFormat()
- Calculator::add in modules/
price/ src/ Calculator.php - Adds the second number to the first number.
- Calculator::compare in modules/
price/ src/ Calculator.php - Compares the first number to the second number.
- Calculator::divide in modules/
price/ src/ Calculator.php - Divides the first number by the second number.
- Calculator::multiply in modules/
price/ src/ Calculator.php - Multiplies the first number by the second number.
- Calculator::round in modules/
price/ src/ Calculator.php - Rounds the given number.
File
- modules/
price/ src/ Calculator.php, line 256
Class
- Calculator
- Provides helpers for bcmath-based arithmetic.
Namespace
Drupal\commerce_priceCode
public static function assertNumberFormat($number) {
if (is_float($number)) {
throw new \InvalidArgumentException(sprintf('The provided value "%s" must be a string, not a float.', $number));
}
if (!is_numeric($number)) {
throw new \InvalidArgumentException(sprintf('The provided value "%s" is not a numeric value.', $number));
}
}