Skip to content

Commit

Permalink
updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck ALARY committed Nov 9, 2022
1 parent 98a450f commit 1188b95
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
6 changes: 5 additions & 1 deletion docs/classes/DantSu/PHPImageEditor/Image.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ Create an Image instance from base64 image data.
| Parameter | Type | Description |
|-----------|------|-------------|
| `url` | **string** | Url of the image file |
| `curlOptions` | **array** | cURL options |
| `failOnError` | **bool** | If true, throw an exception if the url cannot be loaded |


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


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


---
> Automatically generated from source code comments on 2022-05-30 using [phpDocumentor](http://www.phpdoc.org/)
> Automatically generated from source code comments on 2022-11-09 using [phpDocumentor](http://www.phpdoc.org/)
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ This is an automatically generated documentation for **PHP Image Editor**.


---
> Automatically generated from source code comments on 2022-05-30 using [phpDocumentor](http://www.phpdoc.org/)
> Automatically generated from source code comments on 2022-11-09 using [phpDocumentor](http://www.phpdoc.org/)
21 changes: 10 additions & 11 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ public function base64(string $base64): Image
* @param array $curlOptions cURL options
* @param bool $failOnError If true, throw an exception if the url cannot be loaded
* @return Image Return Image instance
* @throws \Exception
*/
public static function fromCurl(string $url, array $curlOptions = [], bool $failOnError = false): Image
{
Expand All @@ -301,6 +302,7 @@ public static function fromCurl(string $url, array $curlOptions = [], bool $fail
* @param array $curlOptions cURL options
* @param bool $failOnError If true, throw an exception if the url cannot be loaded
* @return $this Fluent interface
* @throws \Exception
*/
public function curl(string $url, array $curlOptions = [], bool $failOnError = false): Image
{
Expand All @@ -309,18 +311,18 @@ public function curl(string $url, array $curlOptions = [], bool $failOnError = f
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_TIMEOUT => 5,
];

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt_array($curl, $defaultCurlOptions + $curlOptions);

$image = curl_exec($curl);
$curl = \curl_init();
\curl_setopt($curl, CURLOPT_URL, $url);
\curl_setopt_array($curl, $defaultCurlOptions + $curlOptions);

if($failOnError && curl_errno($curl)){
throw new \Exception(curl_error($curl));
$image = \curl_exec($curl);

if($failOnError && \curl_errno($curl)){
throw new \Exception(\curl_error($curl));
}

curl_close($curl);
\curl_close($curl);

if ($image === false) {
return $this->resetFields();
Expand Down Expand Up @@ -620,13 +622,10 @@ private static function formatColor(string $stringColor): string
$g = \substr($stringColor, 1, 1);
$b = \substr($stringColor, 2, 1);
return $r . $r . $g . $g . $b . $b . '00';
break;
case 6 :
return $stringColor . '00';
break;
case 8 :
return $stringColor;
break;
default:
return '00000000';
}
Expand Down

0 comments on commit 1188b95

Please sign in to comment.