| 1 | <?php namespace Modules\Media\Image; |
||
| 3 | class Thumbnail |
||
| 4 | { |
||
| 5 | /** |
||
| 6 | * @var array |
||
| 7 | */ |
||
| 8 | private $filters; |
||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | private $name; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @param $name |
||
| 16 | * @param $filters |
||
| 17 | */ |
||
| 18 | private function __construct($name, $filters) |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param $thumbnailDefinition |
||
| 26 | * @return static |
||
| 27 | */ |
||
| 28 | public static function make($thumbnailDefinition) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Make multiple thumbnail classes with the given array |
||
| 37 | * @param array $thumbnailDefinitions |
||
| 38 | * @return array |
||
| 39 | */ |
||
| 40 | public static function makeMultiple(array $thumbnailDefinitions) |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Return the thumbnail name |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | public function name() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return array |
||
| 62 | */ |
||
| 63 | public function filters() |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Return the first width option found in the filters |
||
| 70 | * @return int |
||
| 71 | */ |
||
| 72 | public function width() |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Return the first height option found in the filters |
||
| 79 | * @return int |
||
| 80 | */ |
||
| 81 | public function height() |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Get the thumbnail size in format: width x height |
||
| 88 | * @return string |
||
| 89 | */ |
||
| 90 | public function size() |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Get the first found key in filters |
||
| 97 | * @param string $key |
||
| 98 | * @return int |
||
| 99 | */ |
||
| 100 | private function getFirst($key) |
||
| 108 | } |
||
| 109 |