IntegerOverflowException.php 612 B

123456789101112131415161718192021222324252627
  1. <?php
  2. declare(strict_types=1);
  3. namespace Brick\Math\Exception;
  4. use Brick\Math\BigInteger;
  5. /**
  6. * Exception thrown when an integer overflow occurs.
  7. */
  8. class IntegerOverflowException extends MathException
  9. {
  10. /**
  11. * @param BigInteger $value
  12. *
  13. * @return IntegerOverflowException
  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. return new self(\sprintf($message, (string) $value, PHP_INT_MIN, PHP_INT_MAX));
  21. }
  22. }