@@ -288,6 +288,7 @@ public function base64(string $base64): Image
288
288
* @param array $curlOptions cURL options
289
289
* @param bool $failOnError If true, throw an exception if the url cannot be loaded
290
290
* @return Image Return Image instance
291
+ * @throws \Exception
291
292
*/
292
293
public static function fromCurl (string $ url , array $ curlOptions = [], bool $ failOnError = false ): Image
293
294
{
@@ -301,6 +302,7 @@ public static function fromCurl(string $url, array $curlOptions = [], bool $fail
301
302
* @param array $curlOptions cURL options
302
303
* @param bool $failOnError If true, throw an exception if the url cannot be loaded
303
304
* @return $this Fluent interface
305
+ * @throws \Exception
304
306
*/
305
307
public function curl (string $ url , array $ curlOptions = [], bool $ failOnError = false ): Image
306
308
{
@@ -309,18 +311,18 @@ public function curl(string $url, array $curlOptions = [], bool $failOnError = f
309
311
CURLOPT_RETURNTRANSFER => 1 ,
310
312
CURLOPT_TIMEOUT => 5 ,
311
313
];
312
-
313
- $ curl = curl_init ();
314
- curl_setopt ($ curl , CURLOPT_URL , $ url );
315
- curl_setopt_array ($ curl , $ defaultCurlOptions + $ curlOptions );
316
314
317
- $ image = curl_exec ($ curl );
315
+ $ curl = \curl_init ();
316
+ \curl_setopt ($ curl , CURLOPT_URL , $ url );
317
+ \curl_setopt_array ($ curl , $ defaultCurlOptions + $ curlOptions );
318
318
319
- if ($ failOnError && curl_errno ($ curl )){
320
- throw new \Exception (curl_error ($ curl ));
319
+ $ image = \curl_exec ($ curl );
320
+
321
+ if ($ failOnError && \curl_errno ($ curl )){
322
+ throw new \Exception (\curl_error ($ curl ));
321
323
}
322
324
323
- curl_close ($ curl );
325
+ \ curl_close ($ curl );
324
326
325
327
if ($ image === false ) {
326
328
return $ this ->resetFields ();
@@ -620,13 +622,10 @@ private static function formatColor(string $stringColor): string
620
622
$ g = \substr ($ stringColor , 1 , 1 );
621
623
$ b = \substr ($ stringColor , 2 , 1 );
622
624
return $ r . $ r . $ g . $ g . $ b . $ b . '00 ' ;
623
- break ;
624
625
case 6 :
625
626
return $ stringColor . '00 ' ;
626
- break ;
627
627
case 8 :
628
628
return $ stringColor ;
629
- break ;
630
629
default :
631
630
return '00000000 ' ;
632
631
}
0 commit comments