You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.1 KiB

  1. <?php
  2. abstract class Image extends File
  3. {
  4. public $width;
  5. public $height;
  6. public $type;
  7. public $size;
  8. public $original_filename;
  9. public $variants = array();
  10. protected static $max_width;
  11. protected static $max_height;
  12. protected static $sizes = array();
  13. /**
  14. * @param $class string|StdClass
  15. * @throws ErrorException
  16. */
  17. public static function checkSubClass($class)
  18. {
  19. if (!self::getIsSubClass($class)) {
  20. throw new ErrorException('Class "' . $class . '" mast be extend of "Image".');
  21. }
  22. }
  23. /**
  24. * @param $class string|StdClass
  25. * @return bool
  26. */
  27. public static function getIsSubClass($class)
  28. {
  29. return (get_parent_class($class) == __CLASS__);
  30. }
  31. public static function getSizes()
  32. {
  33. return static::$sizes;
  34. }
  35. public static function getMaxWidth()
  36. {
  37. return static::$max_width;
  38. }
  39. public static function getMaxHeight()
  40. {
  41. return static::$max_height;
  42. }
  43. public function getVariant($size)
  44. {
  45. return parent::getImageVariant($size);
  46. }
  47. }