Skip to content

Commit 1188b95

Browse files
committed
updating documentation
1 parent 98a450f commit 1188b95

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

docs/classes/DantSu/PHPImageEditor/Image.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ Create an Image instance from base64 image data.
490490
| Parameter | Type | Description |
491491
|-----------|------|-------------|
492492
| `url` | **string** | Url of the image file |
493+
| `curlOptions` | **array** | cURL options |
494+
| `failOnError` | **bool** | If true, throw an exception if the url cannot be loaded |
493495

494496

495497
#### Return Value:
@@ -515,6 +517,8 @@ Open image from URL with cURL.
515517
| Parameter | Type | Description |
516518
|-----------|------|-------------|
517519
| `url` | **string** | Url of the image file |
520+
| `curlOptions` | **array** | cURL options |
521+
| `failOnError` | **bool** | If true, throw an exception if the url cannot be loaded |
518522

519523

520524
#### Return Value:
@@ -1430,4 +1434,4 @@ Get image GIF base64 data for <img src=""> tag.
14301434

14311435

14321436
---
1433-
> Automatically generated from source code comments on 2022-05-30 using [phpDocumentor](http://www.phpdoc.org/)
1437+
> Automatically generated from source code comments on 2022-11-09 using [phpDocumentor](http://www.phpdoc.org/)

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ This is an automatically generated documentation for **PHP Image Editor**.
1919

2020

2121
---
22-
> Automatically generated from source code comments on 2022-05-30 using [phpDocumentor](http://www.phpdoc.org/)
22+
> Automatically generated from source code comments on 2022-11-09 using [phpDocumentor](http://www.phpdoc.org/)

src/Image.php

+10-11
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)