1 | <?php |
||
7 | class Conversion |
||
8 | { |
||
9 | /** |
||
10 | * @var string name |
||
11 | */ |
||
12 | protected $name = ''; |
||
13 | |||
14 | /** |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $manipulations = []; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $performOnCollections = []; |
||
23 | |||
24 | /** |
||
25 | * @var bool |
||
26 | */ |
||
27 | protected $performOnQueue = true; |
||
28 | |||
29 | public function __construct(string $name) |
||
33 | |||
34 | public static function create(string $name) |
||
38 | |||
39 | public function getName() : string |
||
43 | |||
44 | /** |
||
45 | * Get the manipulations of this conversion. |
||
46 | */ |
||
47 | public function getManipulations() : array |
||
58 | |||
59 | /** |
||
60 | * Set the manipulations for this conversion. |
||
61 | * |
||
62 | * @param $manipulations |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function setManipulations(...$manipulations) |
||
72 | |||
73 | /** |
||
74 | * Add the given manipulation as the first manipulation. |
||
75 | * |
||
76 | * @param array $manipulation |
||
77 | * |
||
78 | * @return $this |
||
79 | */ |
||
80 | public function addAsFirstManipulation(array $manipulation) |
||
86 | |||
87 | /** |
||
88 | * Set the collection names on which this conversion must be performed. |
||
89 | * |
||
90 | * @param array $collectionNames |
||
91 | * |
||
92 | * @return $this |
||
93 | */ |
||
94 | public function performOnCollections(...$collectionNames) |
||
100 | |||
101 | /* |
||
102 | * Determine if this conversion should be performed on the given |
||
103 | * collection. |
||
104 | */ |
||
105 | public function shouldBePerformedOn(string $collectionName) : bool |
||
118 | |||
119 | /** |
||
120 | * Mark this conversion as one that should be queued. |
||
121 | * |
||
122 | * @return $this |
||
123 | */ |
||
124 | public function queued() |
||
130 | |||
131 | /** |
||
132 | * Mark this conversion as one that should not be queued. |
||
133 | * |
||
134 | * @return $this |
||
135 | */ |
||
136 | public function nonQueued() |
||
142 | |||
143 | /* |
||
144 | * Determine if the conversion should be queued. |
||
145 | */ |
||
146 | public function shouldBeQueued() : bool |
||
150 | |||
151 | /* |
||
152 | * Get the extension that the result of this conversion must have. |
||
153 | */ |
||
154 | public function getResultExtension(string $originalFileExtension = '') : string |
||
162 | |||
163 | /* |
||
164 | * Determine if the given manipulations contain a format manipulation. |
||
165 | */ |
||
166 | protected function containsFormatManipulation(array $manipulations) : bool |
||
176 | |||
177 | /** |
||
178 | * Set the target width. |
||
179 | * Matches with Glide's 'w'-parameter. |
||
180 | * |
||
181 | * @param int $width |
||
182 | * |
||
183 | * @return $this |
||
184 | * |
||
185 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
186 | */ |
||
187 | public function setWidth(int $width) |
||
197 | |||
198 | /** |
||
199 | * Set the target height. |
||
200 | * Matches with Glide's 'h'-parameter. |
||
201 | * |
||
202 | * @param int $height |
||
203 | * |
||
204 | * @return $this |
||
205 | * |
||
206 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
207 | */ |
||
208 | public function setHeight(int $height) |
||
218 | |||
219 | /** |
||
220 | * Set the target format. |
||
221 | * Matches with Glide's 'fm'-parameter. |
||
222 | * |
||
223 | * @param string $format |
||
224 | * |
||
225 | * @return $this |
||
226 | * |
||
227 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
228 | */ |
||
229 | public function setFormat(string $format) |
||
241 | |||
242 | /** |
||
243 | * Set the target fit. |
||
244 | * Matches with Glide's 'fit'-parameter. |
||
245 | * |
||
246 | * @param string $fit |
||
247 | * |
||
248 | * @return $this |
||
249 | * |
||
250 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
251 | */ |
||
252 | public function setFit(string $fit) |
||
279 | |||
280 | /** |
||
281 | * Crops the image to specific dimensions prior to any other resize operations. |
||
282 | * |
||
283 | * @param int $width |
||
284 | * @param int $height |
||
285 | * @param int $x |
||
286 | * @param int $y |
||
287 | * |
||
288 | * @return $this |
||
289 | * |
||
290 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
291 | */ |
||
292 | public function setCrop(int $width, int $height, int $x, int $y) |
||
304 | |||
305 | /** |
||
306 | * Set the manipulation parameter. |
||
307 | * |
||
308 | * @param string $name |
||
309 | * @param string $value |
||
310 | * |
||
311 | * @return $this |
||
312 | */ |
||
313 | public function setManipulationParameter(string $name, string $value) |
||
321 | } |
||
322 |