class NumberFormatException
Exception thrown when attempting to create a number from a string with an invalid format.
Hierarchy
- class \Brick\Math\Exception\MathException extends \Brick\Math\Exception\Exception
- class \Brick\Math\Exception\NumberFormatException extends \Brick\Math\Exception\MathException
Expanded class hierarchy of NumberFormatException
3 files declare their use of NumberFormatException
- BigInteger.php in vendor/
brick/ math/ src/ BigInteger.php - BigNumber.php in vendor/
brick/ math/ src/ BigNumber.php - BigRational.php in vendor/
brick/ math/ src/ BigRational.php
File
-
vendor/
brick/ math/ src/ Exception/ NumberFormatException.php, line 10
Namespace
Brick\Math\ExceptionView source
class NumberFormatException extends MathException {
public static function invalidFormat(string $value) : self {
return new self(\sprintf('The given value "%s" does not represent a valid number.', $value));
}
/**
* @param string $char The failing character.
*
* @psalm-pure
*/
public static function charNotInAlphabet(string $char) : self {
$ord = \ord($char);
if ($ord < 32 || $ord > 126) {
$char = \strtoupper(\dechex($ord));
if ($ord < 10) {
$char = '0' . $char;
}
}
else {
$char = '"' . $char . '"';
}
return new self(\sprintf('Char %s is not a valid character in the given alphabet.', $char));
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
NumberFormatException::charNotInAlphabet | public static | function | @psalm-pure |
NumberFormatException::invalidFormat | public static | function |