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.

71 lines
1.4 KiB

11 years ago
  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. /**
  10. * @var ImageVariant[]
  11. */
  12. public $variants = array();
  13. protected static $max_width;
  14. protected static $max_height;
  15. protected static $sizes = array();
  16. public static function getClassName()
  17. {
  18. return get_called_class();
  19. }
  20. /**
  21. * @param $class string|StdClass
  22. * @throws ErrorException
  23. */
  24. public static function checkSubClass($class)
  25. {
  26. if (!self::getIsSubClass($class)) {
  27. throw new ErrorException('Class "' . $class . '" mast be extend of "Image".');
  28. }
  29. }
  30. /**
  31. * @param $class string|StdClass
  32. * @return bool
  33. */
  34. public static function getIsSubClass($class)
  35. {
  36. return (get_parent_class($class) == __CLASS__);
  37. }
  38. public static function getSizes()
  39. {
  40. return static::$sizes;
  41. }
  42. public static function getMaxWidth()
  43. {
  44. return static::$max_width;
  45. }
  46. public static function getMaxHeight()
  47. {
  48. return static::$max_height;
  49. }
  50. /**
  51. * @param $size
  52. * @param $force_create
  53. * @return ImageVariant
  54. */
  55. public function getVariant($size, $force_create = false)
  56. {
  57. return parent::getImageVariant($size, $force_create);
  58. }
  59. }