| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Brick\Math\Exception; |
| 6 | |
| 7 | use Brick\Math\BigInteger; |
| 8 | |
| 9 | /** |
| 10 | * Exception thrown when an integer overflow occurs. |
| 11 | */ |
| 12 | class IntegerOverflowException extends MathException |
| 13 | { |
| 14 | /** |
| 15 | * @psalm-pure |
| 16 | */ |
| 17 | public static function toIntOverflow(BigInteger $value) : IntegerOverflowException |
| 18 | { |
| 19 | $message = '%s is out of range %d to %d and cannot be represented as an integer.'; |
| 20 | |
| 21 | return new self(\sprintf($message, (string) $value, PHP_INT_MIN, PHP_INT_MAX)); |
| 22 | } |
| 23 | } |