|
24 | 24 | use MegaOptim\Responses\Response; |
25 | 25 | use MegaOptim\Services\OptimizerService; |
26 | 26 | use MegaOptim\Tools\FileSystem; |
| 27 | +use MegaOptim\Tools\PATH; |
| 28 | +use MegaOptim\Tools\URL; |
27 | 29 |
|
28 | 30 | class Optimizer { |
29 | 31 |
|
@@ -163,11 +165,11 @@ public function run( $resource, $args = array(), $local_wait = false ) { |
163 | 165 |
|
164 | 166 | /** |
165 | 167 | * Returns the results of the process |
166 | | - * |
167 | 168 | * @param $process_id |
168 | | - * @param $max_wait_seconds |
| 169 | + * @param int $max_wait_seconds |
169 | 170 | * |
170 | 171 | * @return Response |
| 172 | + * @throws \Exception |
171 | 173 | */ |
172 | 174 | public function get_result( $process_id, $max_wait_seconds = 5 ) { |
173 | 175 | $result = $this->service->get_result( $process_id, $max_wait_seconds ); |
@@ -201,38 +203,7 @@ public static function validate( $resource, $args ) { |
201 | 203 | * @return bool |
202 | 204 | */ |
203 | 205 | public static function is_url( $resource ) { |
204 | | - return ! ! filter_var( $resource, FILTER_VALIDATE_URL ); |
205 | | - } |
206 | | - |
207 | | - /** |
208 | | - * Check if the given path is support image type (jpg,png,gif,svg) |
209 | | - * |
210 | | - * @param string $path - The local temporary path |
211 | | - * |
212 | | - * @return bool |
213 | | - */ |
214 | | - public static function is_supported( $path ) { |
215 | | - return array_key_exists( pathinfo( $path, PATHINFO_EXTENSION ), self::accepted_types() ); |
216 | | - } |
217 | | - |
218 | | - /** |
219 | | - * Return the accepted file types |
220 | | - * @return array |
221 | | - */ |
222 | | - public static function accepted_types() { |
223 | | - return array( |
224 | | - 'png' => 'image/png', |
225 | | - 'jpe' => 'image/jpeg', |
226 | | - 'jpeg' => 'image/jpeg', |
227 | | - 'jpg' => 'image/jpeg', |
228 | | - 'gif' => 'image/gif', |
229 | | - //'bmp' => 'image/bmp', |
230 | | - //'ico' => 'image/vnd.microsoft.icon', |
231 | | - //'tiff' => 'image/tiff', |
232 | | - //'tif' => 'image/tiff', |
233 | | - //'svg' => 'image/svg+xml', |
234 | | - //'svgz' => 'image/svg+xml', |
235 | | - ); |
| 206 | + return URL::validate($resource); |
236 | 207 | } |
237 | 208 |
|
238 | 209 | /** |
|
0 commit comments