@@ -288,6 +288,7 @@ public function base64(string $base64): Image
288288 * @param array $curlOptions cURL options
289289 * @param bool $failOnError If true, throw an exception if the url cannot be loaded
290290 * @return Image Return Image instance
291+ * @throws \Exception
291292 */
292293 public static function fromCurl (string $ url , array $ curlOptions = [], bool $ failOnError = false ): Image
293294 {
@@ -301,6 +302,7 @@ public static function fromCurl(string $url, array $curlOptions = [], bool $fail
301302 * @param array $curlOptions cURL options
302303 * @param bool $failOnError If true, throw an exception if the url cannot be loaded
303304 * @return $this Fluent interface
305+ * @throws \Exception
304306 */
305307 public function curl (string $ url , array $ curlOptions = [], bool $ failOnError = false ): Image
306308 {
@@ -309,18 +311,18 @@ public function curl(string $url, array $curlOptions = [], bool $failOnError = f
309311 CURLOPT_RETURNTRANSFER => 1 ,
310312 CURLOPT_TIMEOUT => 5 ,
311313 ];
312-
313- $ curl = curl_init ();
314- curl_setopt ($ curl , CURLOPT_URL , $ url );
315- curl_setopt_array ($ curl , $ defaultCurlOptions + $ curlOptions );
316314
317- $ image = curl_exec ($ curl );
315+ $ curl = \curl_init ();
316+ \curl_setopt ($ curl , CURLOPT_URL , $ url );
317+ \curl_setopt_array ($ curl , $ defaultCurlOptions + $ curlOptions );
318318
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 ));
321323 }
322324
323- curl_close ($ curl );
325+ \ curl_close ($ curl );
324326
325327 if ($ image === false ) {
326328 return $ this ->resetFields ();
@@ -620,13 +622,10 @@ private static function formatColor(string $stringColor): string
620622 $ g = \substr ($ stringColor , 1 , 1 );
621623 $ b = \substr ($ stringColor , 2 , 1 );
622624 return $ r . $ r . $ g . $ g . $ b . $ b . '00 ' ;
623- break ;
624625 case 6 :
625626 return $ stringColor . '00 ' ;
626- break ;
627627 case 8 :
628628 return $ stringColor ;
629- break ;
630629 default :
631630 return '00000000 ' ;
632631 }
0 commit comments