9
9
use Intervention \Image \Drivers \Gd \Driver as GdDriver ;
10
10
use Intervention \Image \Drivers \Imagick \Driver as ImagickDriver ;
11
11
use Intervention \Image \Exceptions \DriverException ;
12
+ use Intervention \Image \Exceptions \InputException ;
12
13
use Intervention \Image \Interfaces \DecoderInterface ;
13
14
use Intervention \Image \Interfaces \ImageManagerInterface ;
14
15
@@ -20,6 +21,7 @@ final class ImageManager implements ImageManagerInterface
20
21
* @link https://image.intervention.io/v3/basics/image-manager#create-a-new-image-manager-instance
21
22
* @param string|DriverInterface $driver
22
23
* @throws DriverException
24
+ * @throws InputException
23
25
* @param mixed $options
24
26
*/
25
27
public function __construct (string |DriverInterface $ driver , mixed ...$ options )
@@ -34,6 +36,7 @@ public function __construct(string|DriverInterface $driver, mixed ...$options)
34
36
* @param string|DriverInterface $driver
35
37
* @param mixed $options
36
38
* @throws DriverException
39
+ * @throws InputException
37
40
* @return ImageManager
38
41
*/
39
42
public static function withDriver (string |DriverInterface $ driver , mixed ...$ options ): self
@@ -47,6 +50,7 @@ public static function withDriver(string|DriverInterface $driver, mixed ...$opti
47
50
* @link https://image.intervention.io/v3/basics/image-manager#static-gd-driver-constructor
48
51
* @param mixed $options
49
52
* @throws DriverException
53
+ * @throws InputException
50
54
* @return ImageManager
51
55
*/
52
56
public static function gd (mixed ...$ options ): self
@@ -60,6 +64,7 @@ public static function gd(mixed ...$options): self
60
64
* @link https://image.intervention.io/v3/basics/image-manager#static-imagick-driver-constructor
61
65
* @param mixed $options
62
66
* @throws DriverException
67
+ * @throws InputException
63
68
* @return ImageManager
64
69
*/
65
70
public static function imagick (mixed ...$ options ): self
@@ -119,6 +124,7 @@ public function driver(): DriverInterface
119
124
* @param string|DriverInterface $driver
120
125
* @param mixed $options
121
126
* @throws DriverException
127
+ * @throws InputException
122
128
* @return DriverInterface
123
129
*/
124
130
private static function resolveDriver (string |DriverInterface $ driver , mixed ...$ options ): DriverInterface
@@ -132,6 +138,12 @@ class_exists($driver) => new $driver(),
132
138
),
133
139
};
134
140
141
+ if (!$ driver instanceof DriverInterface) {
142
+ throw new DriverException (
143
+ 'Unable to resolve driver. Driver object must implement ' . DriverInterface::class . '. ' ,
144
+ );
145
+ }
146
+
135
147
$ driver ->config ()->setOptions (...$ options );
136
148
137
149
return $ driver ;
0 commit comments