class-file-size-exception.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Exceptions
  6. */
  7. /**
  8. * Represents named methods for exceptions.
  9. */
  10. class WPSEO_File_Size_Exception extends Exception {
  11. /**
  12. * Gets the exception for an externally hosted file.
  13. *
  14. * @param string $file_url The file url.
  15. *
  16. * @return WPSEO_File_Size_Exception Instance of the exception.
  17. */
  18. public static function externally_hosted( $file_url ) {
  19. $message = sprintf(
  20. /* translators: %1$s expands to the requested url */
  21. __( 'Cannot get the size of %1$s because it is hosted externally.', 'wordpress-seo' ),
  22. $file_url
  23. );
  24. return new self( $message );
  25. }
  26. /**
  27. * Gets the exception for when a unknown error occurs.
  28. *
  29. * @param string $file_url The file url.
  30. *
  31. * @return WPSEO_File_Size_Exception Instance of the exception.
  32. */
  33. public static function unknown_error( $file_url ) {
  34. $message = sprintf(
  35. /* translators: %1$s expands to the requested url */
  36. __( 'Cannot get the size of %1$s because of unknown reasons.', 'wordpress-seo' ),
  37. $file_url
  38. );
  39. return new self( $message );
  40. }
  41. }