diff --git a/README.md b/README.md index e3ee9e3..6d5da0d 100644 --- a/README.md +++ b/README.md @@ -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" } } ``` diff --git a/src/Request/Message/Body/JsonBody.php b/src/Request/Message/Body/JsonBody.php index bc909e9..bec15e0 100644 --- a/src/Request/Message/Body/JsonBody.php +++ b/src/Request/Message/Body/JsonBody.php @@ -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.');