Skip to content

Commit

Permalink
Merge pull request #2 from andriusbaliutis/master
Browse files Browse the repository at this point in the history
add validation to configureCurl method
  • Loading branch information
Bonscho authored Aug 2, 2024
2 parents fa0cf13 + fd96892 commit b5e5b2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A JSON HTTP client library. This project also is the reference implementation fo
```{json}
{
"require": {
"chroma-x/json-http-client": "~3.0"
"chroma-x/json-http-client": "~4.0"
}
}
```
Expand Down
6 changes: 5 additions & 1 deletion src/Request/Message/Body/JsonBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ public function __construct(array $bodyData)
$this->bodyData = $bodyData;
}

public function configureCurl(\CurlHandle $curl): self
public function configureCurl(\CurlHandle|false $curl): self
{
if ($curl === false) {
throw new \TypeError('cURL is not a valid CurlHandle class.');
}

$jsonBody = json_encode($this->bodyData);
if ($jsonBody === false) {
throw new HttpRequestMessageException('JSON body data not serializable.');
Expand Down

0 comments on commit b5e5b2a

Please sign in to comment.