ThrowableUtils.php 730 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\ErrorHandler;
  11. /**
  12. * @internal
  13. */
  14. class ThrowableUtils
  15. {
  16. public static function getSeverity(\Throwable $throwable): int
  17. {
  18. if ($throwable instanceof \ErrorException) {
  19. return $throwable->getSeverity();
  20. }
  21. if ($throwable instanceof \ParseError) {
  22. return \E_PARSE;
  23. }
  24. if ($throwable instanceof \TypeError) {
  25. return \E_RECOVERABLE_ERROR;
  26. }
  27. return \E_ERROR;
  28. }
  29. }