Skip to content

Commit b5e5b2a

Browse files
authored
Merge pull request #2 from andriusbaliutis/master
add validation to configureCurl method
2 parents fa0cf13 + fd96892 commit b5e5b2a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A JSON HTTP client library. This project also is the reference implementation fo
1414
```{json}
1515
{
1616
"require": {
17-
"chroma-x/json-http-client": "~3.0"
17+
"chroma-x/json-http-client": "~4.0"
1818
}
1919
}
2020
```

src/Request/Message/Body/JsonBody.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ public function __construct(array $bodyData)
2222
$this->bodyData = $bodyData;
2323
}
2424

25-
public function configureCurl(\CurlHandle $curl): self
25+
public function configureCurl(\CurlHandle|false $curl): self
2626
{
27+
if ($curl === false) {
28+
throw new \TypeError('cURL is not a valid CurlHandle class.');
29+
}
30+
2731
$jsonBody = json_encode($this->bodyData);
2832
if ($jsonBody === false) {
2933
throw new HttpRequestMessageException('JSON body data not serializable.');

0 commit comments

Comments
 (0)