Commit 7be577ea authored by Nicolas Widart's avatar Nicolas Widart

Add a security mesure for required options

parent d84753bb
<?php namespace Modules\Media\Image\Intervention\Manipulations; <?php namespace Modules\Media\Image\Intervention\Manipulations;
use InvalidArgumentException;
use Modules\Media\Image\ImageHandlerInterface; use Modules\Media\Image\ImageHandlerInterface;
class Crop implements ImageHandlerInterface class Crop implements ImageHandlerInterface
...@@ -12,6 +13,10 @@ class Crop implements ImageHandlerInterface ...@@ -12,6 +13,10 @@ class Crop implements ImageHandlerInterface
*/ */
public function handle($image, $options) public function handle($image, $options)
{ {
if (!isset($options['width']) or !isset($options['height'])) {
throw new InvalidArgumentException('A width and height parameter are required');
}
return $image->crop($options['width'], $options['height']); return $image->crop($options['width'], $options['height']);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment