public static function Calculator::assertNumberFormat in Physical Fields 8
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 src/
Calculator.php - Adds the second number to the first number.
- Calculator::compare in src/
Calculator.php - Compares the first number to the second number.
- Calculator::divide in src/
Calculator.php - Divides the first number by the second number.
- Calculator::multiply in src/
Calculator.php - Multiplies the first number by the second number.
- Calculator::round in src/
Calculator.php - Rounds the given number.
File
- src/
Calculator.php, line 258
Class
- Calculator
- Provides helpers for bcmath-based arithmetic.
Namespace
Drupal\physicalCode
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));
}
}