← All changes
|
includes/sdk/google/brick/math/src/Exception/NumberFormatException.php
+7
-5
1.2.4
→
1.4.1
View file →
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | declare (strict_types=1); |
| 4 | -namespace Dudlewebs\WPMCS\Brick\Math\Exception; | |
| 4 | +namespace Dudlewebs\WPMCS\GCP\Brick\Math\Exception; | |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * Exception thrown when attempting to create a number from a string with an invalid format. |
| 8 | 8 | */ |
| @@ -7,16 +7,18 @@ | ||
| 7 | 7 | * Exception thrown when attempting to create a number from a string with an invalid format. |
| 8 | 8 | */ |
| 9 | 9 | class NumberFormatException extends MathException |
| 10 | 10 | { |
| 11 | + public static function invalidFormat(string $value) : self | |
| 12 | + { | |
| 13 | + return new self(\sprintf('The given value "%s" does not represent a valid number.', $value)); | |
| 14 | + } | |
| 11 | 15 | /** |
| 12 | 16 | * @param string $char The failing character. |
| 13 | 17 | * |
| 14 | - * @return NumberFormatException | |
| 15 | - * | |
| 16 | 18 | * @psalm-pure |
| 17 | 19 | */ |
| 18 | - public static function charNotInAlphabet(string $char): self | |
| 20 | + public static function charNotInAlphabet(string $char) : self | |
| 19 | 21 | { |
| 20 | 22 | $ord = \ord($char); |
| 21 | 23 | if ($ord < 32 || $ord > 126) { |
| 22 | 24 | $char = \strtoupper(\dechex($ord)); |
| @@ -25,7 +27,7 @@ | ||
| 25 | 27 | } |
| 26 | 28 | } else { |
| 27 | 29 | $char = '"' . $char . '"'; |
| 28 | 30 | } |
| 29 | - return new self(sprintf('Char %s is not a valid character in the given alphabet.', $char)); | |
| 31 | + return new self(\sprintf('Char %s is not a valid character in the given alphabet.', $char)); | |
| 30 | 32 | } |
| 31 | 33 | } |