DivisionByZeroException.php 736 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. declare(strict_types=1);
  3. namespace Brick\Math\Exception;
  4. /**
  5. * Exception thrown when a division by zero occurs.
  6. */
  7. class DivisionByZeroException extends MathException
  8. {
  9. /**
  10. * @psalm-pure
  11. */
  12. public static function divisionByZero() : DivisionByZeroException
  13. {
  14. return new self('Division by zero.');
  15. }
  16. /**
  17. * @psalm-pure
  18. */
  19. public static function modulusMustNotBeZero() : DivisionByZeroException
  20. {
  21. return new self('The modulus must not be zero.');
  22. }
  23. /**
  24. * @psalm-pure
  25. */
  26. public static function denominatorMustNotBeZero() : DivisionByZeroException
  27. {
  28. return new self('The denominator of a rational number cannot be zero.');
  29. }
  30. }