diff --git a/src/ImageManager.php b/src/ImageManager.php index 6272f21d..20487cc5 100644 --- a/src/ImageManager.php +++ b/src/ImageManager.php @@ -9,6 +9,7 @@ use Intervention\Image\Drivers\Gd\Driver as GdDriver; use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver; use Intervention\Image\Exceptions\DriverException; +use Intervention\Image\Exceptions\InputException; use Intervention\Image\Interfaces\DecoderInterface; use Intervention\Image\Interfaces\ImageManagerInterface; @@ -20,6 +21,7 @@ final class ImageManager implements ImageManagerInterface * @link https://image.intervention.io/v3/basics/image-manager#create-a-new-image-manager-instance * @param string|DriverInterface $driver * @throws DriverException + * @throws InputException * @param mixed $options */ public function __construct(string|DriverInterface $driver, mixed ...$options) @@ -34,6 +36,7 @@ public function __construct(string|DriverInterface $driver, mixed ...$options) * @param string|DriverInterface $driver * @param mixed $options * @throws DriverException + * @throws InputException * @return ImageManager */ public static function withDriver(string|DriverInterface $driver, mixed ...$options): self @@ -47,6 +50,7 @@ public static function withDriver(string|DriverInterface $driver, mixed ...$opti * @link https://image.intervention.io/v3/basics/image-manager#static-gd-driver-constructor * @param mixed $options * @throws DriverException + * @throws InputException * @return ImageManager */ public static function gd(mixed ...$options): self @@ -60,6 +64,7 @@ public static function gd(mixed ...$options): self * @link https://image.intervention.io/v3/basics/image-manager#static-imagick-driver-constructor * @param mixed $options * @throws DriverException + * @throws InputException * @return ImageManager */ public static function imagick(mixed ...$options): self @@ -119,6 +124,7 @@ public function driver(): DriverInterface * @param string|DriverInterface $driver * @param mixed $options * @throws DriverException + * @throws InputException * @return DriverInterface */ private static function resolveDriver(string|DriverInterface $driver, mixed ...$options): DriverInterface @@ -132,6 +138,12 @@ class_exists($driver) => new $driver(), ), }; + if (!$driver instanceof DriverInterface) { + throw new DriverException( + 'Unable to resolve driver. Driver object must implement ' . DriverInterface::class . '.', + ); + } + $driver->config()->setOptions(...$options); return $driver;