Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: chroma-x/php-json-http-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.0.8
Choose a base ref
...
head repository: chroma-x/php-json-http-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 11 commits
  • 10 files changed
  • 4 contributors

Commits on Nov 13, 2018

  1. Language level migration.

    Martin Brecht-Precht committed Nov 13, 2018
    Copy the full SHA
    c65b484 View commit details

Commits on Jan 18, 2021

  1. Switched the root namespace and vendor prefix

    Martin Brecht-Precht committed Jan 18, 2021
    Copy the full SHA
    9b6e0b4 View commit details

Commits on Jul 24, 2024

  1. Added PHP8.3

    Bonscho committed Jul 24, 2024
    Copy the full SHA
    f5e925d View commit details

Commits on Aug 2, 2024

  1. Copy the full SHA
    755ff43 View commit details
  2. Copy the full SHA
    7375680 View commit details
  3. Merge pull request #1 from andriusbaliutis/master

    Make package compatible with PHP 8.3
    Bonscho authored Aug 2, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    fa0cf13 View commit details
  4. Copy the full SHA
    c637d00 View commit details
  5. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1c3a54b View commit details
  6. update readme.md

    abmarkenwerk committed Aug 2, 2024
    Copy the full SHA
    f8cc824 View commit details
  7. Copy the full SHA
    fd96892 View commit details
  8. Merge pull request #2 from andriusbaliutis/master

    add validation to configureCurl method
    Bonscho authored Aug 2, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b5e5b2a View commit details
Showing with 130 additions and 255 deletions.
  1. +0 −28 .codeclimate.yml
  2. +0 −29 .travis.yml
  3. +1 −1 LICENSE
  4. +37 −39 README.md
  5. +37 −33 composer.json
  6. +0 −17 phpunit.xml.dist
  7. +26 −65 src/JsonHttpClient.php
  8. +8 −9 src/Request/JsonRequest.php
  9. +12 −19 src/Request/Message/Body/JsonBody.php
  10. +9 −15 src/Response/JsonResponse.php
28 changes: 0 additions & 28 deletions .codeclimate.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Martin Brecht-Precht, Markenwerk GmbH
Copyright (c) 2016 Martin Brecht-Precht, Chroma Experience GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
76 changes: 37 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# PHP JSON HTTP Client

[![Build Status](https://travis-ci.org/markenwerk/php-json-http-client.svg?branch=master)](https://travis-ci.org/markenwerk/php-json-http-client)
[![Test Coverage](https://codeclimate.com/github/markenwerk/php-json-http-client/badges/coverage.svg)](https://codeclimate.com/github/markenwerk/php-json-http-client/coverage)
[![Dependency Status](https://www.versioneye.com/user/projects/5728e298a0ca35004baf7cb7/badge.svg)](https://www.versioneye.com/user/projects/5728e298a0ca35004baf7cb7)
[![Build Status](https://travis-ci.org/chroma-x/php-json-http-client.svg?branch=master)](https://travis-ci.org/chroma-x/php-json-http-client)
[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/6b8db506-121a-4875-8b1d-560b505e0444.svg)](https://insight.sensiolabs.com/projects/6b8db506-121a-4875-8b1d-560b505e0444)
[![Code Climate](https://codeclimate.com/github/markenwerk/php-json-http-client/badges/gpa.svg)](https://codeclimate.com/github/markenwerk/php-json-http-client)
[![Latest Stable Version](https://poser.pugx.org/markenwerk/json-http-client/v/stable)](https://packagist.org/packages/markenwerk/json-http-client)
[![Total Downloads](https://poser.pugx.org/markenwerk/json-http-client/downloads)](https://packagist.org/packages/markenwerk/json-http-client)
[![License](https://poser.pugx.org/markenwerk/json-http-client/license)](https://packagist.org/packages/markenwerk/json-http-client)
[![Code Climate](https://codeclimate.com/github/chroma-x/php-json-http-client/badges/gpa.svg)](https://codeclimate.com/github/chroma-x/php-json-http-client)
[![Latest Stable Version](https://poser.pugx.org/chroma-x/json-http-client/v/stable)](https://packagist.org/packages/chroma-x/json-http-client)
[![Total Downloads](https://poser.pugx.org/chroma-x/json-http-client/downloads)](https://packagist.org/packages/chroma-x/json-http-client)
[![License](https://poser.pugx.org/chroma-x/json-http-client/license)](https://packagist.org/packages/chroma-x/json-http-client)

A JSON HTTP client library. This project also is the reference implementation for extending the [PHP Basic HTTP Client](https://github.com/markenwerk/php-basic-http-client).
A JSON HTTP client library. This project also is the reference implementation for extending the [PHP Basic HTTP Client](https://github.com/chroma-x/php-basic-http-client).

## Installation

```{json}
{
"require": {
"markenwerk/json-http-client": "~3.0"
"chroma-x/json-http-client": "~4.0"
}
}
```
@@ -34,9 +32,9 @@ require_once('path/to/vendor/autoload.php');
#### Preparing the HTTP client

```{php}
use Markenwerk\JsonHttpClient;
use Markenwerk\BasicHttpClient\Request\Authentication;
use Markenwerk\BasicHttpClient\Request\Message;
use ChromaX\JsonHttpClient;
use ChromaX\BasicHttpClient\Request\Authentication;
use ChromaX\BasicHttpClient\Request\Message;
// Instantiating a basic HTTP client with the endpoints URL
// If the endpoint uses the `HTTPS` schema a `HttpsTransport` instance will be used automatically.
@@ -114,7 +112,7 @@ The following example shows the usage with a more detailed configuration.
#### Configuring a HTTP Transport instance

```{php}
use Markenwerk\BasicHttpClient\Request\Transport\HttpTransport;
use ChromaX\BasicHttpClient\Request\Transport\HttpTransport;
// Configuring a Transport instance
$transport = new HttpTransport();
@@ -130,7 +128,7 @@ $transport
#### Configuring a HTTPS Transport instance

```{php}
use Markenwerk\BasicHttpClient\Request\Transport\HttpsTransport;
use ChromaX\BasicHttpClient\Request\Transport\HttpsTransport;
// Configuring a Transport instance
$transport = new HttpsTransport();
@@ -147,10 +145,10 @@ $transport
#### Configuring a Message instance with Body

```{php}
use Markenwerk\BasicHttpClient\Request\Message\Cookie\Cookie;
use Markenwerk\BasicHttpClient\Request\Message\Header\Header;
use Markenwerk\BasicHttpClient\Request\Message\Message;
use Markenwerk\JsonHttpClient\Request\Message\Body\JsonBody;
use ChromaX\BasicHttpClient\Request\Message\Cookie\Cookie;
use ChromaX\BasicHttpClient\Request\Message\Header\Header;
use ChromaX\BasicHttpClient\Request\Message\Message;
use ChromaX\JsonHttpClient\Request\Message\Body\JsonBody;
// Configuring a message Body instance
$messageBody = new JsonBody(array(
@@ -193,12 +191,12 @@ $message->addAdditionalHeader(new Header('Custom-Header', array('AnotherCustomHe

#### Configuring an endpoints URL, build the Request instance and perform the HTTP request

For more information about the usage of the URL object please take a look at the [PHP URL Util](https://github.com/markenwerk/php-url-util) project.
For more information about the usage of the URL object please take a look at the [PHP URL Util](https://github.com/chroma-x/php-url-util) project.

```{php}
use Markenwerk\BasicHttpClient\Request\Authentication\BasicAuthentication;
use Markenwerk\JsonHttpClient\Request\JsonRequest;
use Markenwerk\UrlUtil\Url;
use ChromaX\BasicHttpClient\Request\Authentication\BasicAuthentication;
use ChromaX\JsonHttpClient\Request\JsonRequest;
use ChromaX\UrlUtil\Url;
// Setting up the endpoints URL
$url = new Url('https://john:secret@yourapihere-com-98yq3775xff0.runscope.net:443/path/to/resource?arg1=123#fragment');
@@ -240,8 +238,8 @@ You can add one or more Authentication instances to every Request instance. At t
Required credentials are a *username* and a *password* that get provided to the class constructor as arguments.

```{php}
use Markenwerk\BasicHttpClient\Request\Authentication\BasicAuthentication;
use Markenwerk\JsonHttpClient\Request\JsonRequest;
use ChromaX\BasicHttpClient\Request\Authentication\BasicAuthentication;
use ChromaX\JsonHttpClient\Request\JsonRequest;
// Configuring the authentication
$basicAuthentication = new BasicAuthentication('username', 'password');
@@ -256,8 +254,8 @@ $response = $request->addAuthentication($basicAuthentication);
Required credentials are a *Certificate Authority Certificate*, a *Client Certificate* and the password that is used to decrypt the Client Certificate that get provided to the class constructor as arguments.

```{php}
use Markenwerk\BasicHttpClient\Request\Authentication\ClientCertificateAuthentication;
use Markenwerk\JsonHttpClient\Request\JsonRequest;
use ChromaX\BasicHttpClient\Request\Authentication\ClientCertificateAuthentication;
use ChromaX\JsonHttpClient\Request\JsonRequest;
// Configuring the authentication
$clientCertificateAuthentication = new ClientCertificateAuthentication(
@@ -280,7 +278,7 @@ $response = $request->addAuthentication($clientCertificateAuthentication);
If using the `JsonHttpClient` the response object is returned by the termination methods listed above. If directly using the JsonRequest instance, you can get the JsonResponse object via a getter.

```{php}
// Getting the response Markenwerk\BasicHttpClient\Response\JsonResponse object
// Getting the response ChromaX\BasicHttpClient\Response\JsonResponse object
$response = $request->getResponse();
// Reading the HTTP status code as integer; will return `200`
@@ -289,7 +287,7 @@ echo print_r($response->getStatusCode(), true) . PHP_EOL;
// Reading the HTTP status text as string; will return `HTTP/1.1 200 OK`
echo print_r($response->getStatusText(), true) . PHP_EOL;
// Reading the HTTP response headers as array of Markenwerk\BasicHttpClient\Response\Header\Header objects
// Reading the HTTP response headers as array of ChromaX\BasicHttpClient\Response\Header\Header objects
echo print_r($response->getHeaders(), true) . PHP_EOL;
// Reading the HTTP response body as associative array
@@ -312,7 +310,7 @@ echo print_r($request->getEffectiveStatus(), true) . PHP_EOL;
// Getting the effective raw request headers as string
echo print_r($request->getEffectiveRawHeader(), true) . PHP_EOL;
// Getting the effective request headers as array of `Markenwerk\BasicHttpClient\Request\Message\Header\Header` objects
// Getting the effective request headers as array of `ChromaX\BasicHttpClient\Request\Message\Header\Header` objects
echo print_r($request->getEffectiveHeaders(), true) . PHP_EOL.PHP_EOL;
```

@@ -321,7 +319,7 @@ echo print_r($request->getEffectiveHeaders(), true) . PHP_EOL.PHP_EOL;
## Getting some transactional statistics

```{php}
// Getting the statistics Markenwerk\BasicHttpClient\Response\Statistics\Statistics object
// Getting the statistics ChromaX\BasicHttpClient\Response\Statistics\Statistics object
$statistics = $request->getResponse()->getStatistics();
// Reading the redirection URL if the server responds with an redirect HTTP header and
@@ -355,26 +353,26 @@ echo print_r($statistics->getTotalTime(), true).PHP_EOL;
## Exception handling

PHP JSON HTTP Client provides different exceptions – also provided by the PHP Common Exceptions project – for proper handling.
You can find more information about [PHP Common Exceptions at Github](https://github.com/markenwerk/php-common-exceptions).
You can find more information about [PHP Common Exceptions at Github](https://github.com/chroma-x/php-common-exceptions).

### Exceptions to be expected

In general you should expect that any setter method could thrown an `\InvalidArgumentException`. The following exceptions could get thrown while using PHP Basic HTTP Client.

- `Markenwerk\CommonException\IoException\FileNotFoundException` on configuring a `ClientCertificateAuthentication`instance
- `Markenwerk\CommonException\IoException\FileReadableException` on configuring a `ClientCertificateAuthentication`instance
- `Markenwerk\BasicHttpClient\Exception\HttpRequestAuthenticationException` on performing a request
- `Markenwerk\BasicHttpClient\Exception\HttpRequestException` on performing a request
- `Markenwerk\CommonException\NetworkException\ConnectionTimeoutException` on performing a request
- `Markenwerk\CommonException\NetworkException\CurlException` on performing a request
- `Markenwerk\BasicHttpClient\Exception\HttpResponseException` if parsing the JSON response body fails
- `ChromaX\CommonException\IoException\FileNotFoundException` on configuring a `ClientCertificateAuthentication`instance
- `ChromaX\CommonException\IoException\FileReadableException` on configuring a `ClientCertificateAuthentication`instance
- `ChromaX\BasicHttpClient\Exception\HttpRequestAuthenticationException` on performing a request
- `ChromaX\BasicHttpClient\Exception\HttpRequestException` on performing a request
- `ChromaX\CommonException\NetworkException\ConnectionTimeoutException` on performing a request
- `ChromaX\CommonException\NetworkException\CurlException` on performing a request
- `ChromaX\BasicHttpClient\Exception\HttpResponseException` if parsing the JSON response body fails

---

## Contribution

Contributing to our projects is always very appreciated.
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/markenwerk/php-json-http-client/blob/master/CONTRIBUTING.md) document.**
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/chroma-x/php-json-http-client/blob/master/CONTRIBUTING.md) document.**

## License

70 changes: 37 additions & 33 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
{
"name": "markenwerk/json-http-client",
"type": "library",
"description": "A JSON HTTP client library. This project also is the reference implementation for extending the PHP Basic HTTP Client.",
"keywords": [
"HTTP client",
"RESTful",
"JSON",
"SSL",
"Basic Auth",
"Client Certificate Auth"
],
"homepage": "http://markenwerk.net/",
"license": "MIT",
"authors": [
{
"name": "Martin Brecht-Precht",
"email": "mb@markenwerk.net",
"homepage": "http://markenwerk.net"
}
],
"autoload": {
"psr-4": {
"Markenwerk\\JsonHttpClient\\": "src/"
}
},
"require": {
"php": ">=5.3",
"markenwerk/basic-http-client": "~3.0"
},
"require-dev": {
"phpunit/phpunit": ">=4.8.26",
"codeclimate/php-test-reporter": "dev-master"
}
"name": "chroma-x/json-http-client",
"type": "library",
"description": "A JSON HTTP client library. This project also is the reference implementation for extending the PHP Basic HTTP Client.",
"keywords": [
"HTTP client",
"RESTful",
"JSON",
"SSL",
"Basic Auth",
"Client Certificate Auth"
],
"homepage": "https://chroma-x.de/",
"license": "MIT",
"authors": [
{
"name": "Martin Brecht-Precht",
"email": "mb@chroma-x.de",
"homepage": "https://chroma-x.de"
},
{
"name": "Andrius Baliutis",
"email": "ab@chroma-x.de",
"homepage": "https://chroma-x.de"
}
],
"autoload": {
"psr-4": {
"ChromaX\\JsonHttpClient\\": "src/"
}
},
"require": {
"php": "^8.3",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"chroma-x/basic-http-client": "~4.0"
}
}
17 changes: 0 additions & 17 deletions phpunit.xml.dist

This file was deleted.

91 changes: 26 additions & 65 deletions src/JsonHttpClient.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,37 @@
<?php

namespace Markenwerk\JsonHttpClient;
declare(strict_types=1);

use Markenwerk\BasicHttpClient\HttpClientInterface;
use Markenwerk\BasicHttpClient\Request\Message\Header\Header;
use Markenwerk\BasicHttpClient\Request\RequestInterface;
use Markenwerk\BasicHttpClient\Request\Message\Message;
use Markenwerk\BasicHttpClient\Request\Transport\HttpsTransport;
use Markenwerk\BasicHttpClient\Request\Transport\HttpTransport;
use Markenwerk\BasicHttpClient\Response\ResponseInterface;
use Markenwerk\CommonException\NetworkException\Base\NetworkException;
use Markenwerk\CommonException\NetworkException\ConnectionTimeoutException;
use Markenwerk\JsonHttpClient\Request\JsonRequest;
use Markenwerk\JsonHttpClient\Request\Message\Body\JsonBody;
use Markenwerk\UrlUtil\Url;
namespace ChromaX\JsonHttpClient;

use ChromaX\BasicHttpClient\HttpClientInterface;
use ChromaX\BasicHttpClient\Request\Message\Header\Header;
use ChromaX\BasicHttpClient\Request\RequestInterface;
use ChromaX\BasicHttpClient\Request\Message\Message;
use ChromaX\BasicHttpClient\Request\Transport\HttpsTransport;
use ChromaX\BasicHttpClient\Request\Transport\HttpTransport;
use ChromaX\BasicHttpClient\Response\ResponseInterface;
use ChromaX\CommonException\NetworkException\Base\NetworkException;
use ChromaX\CommonException\NetworkException\ConnectionTimeoutException;
use ChromaX\JsonHttpClient\Request\JsonRequest;
use ChromaX\JsonHttpClient\Request\Message\Body\JsonBody;
use ChromaX\UrlUtil\Url;

/**
* Class JsonHttpClient
*
* @package Markenwerk\JsonHttpClient
* @package ChromaX\JsonHttpClient
*/
class JsonHttpClient implements HttpClientInterface
{

/**
* @var RequestInterface
*/
private $request;
private RequestInterface $request;

/**
* BasicHttpClient constructor.
*
* @param string $endpoint
*/
public function __construct($endpoint)
public function __construct(string $endpoint)
{
$url = new Url($endpoint);
$transport = new HttpTransport();
if (mb_strtoupper($url->getScheme()) == 'HTTPS') {
if (mb_strtoupper($url->getScheme()) === 'HTTPS') {
$transport = new HttpsTransport();
}
$message = new Message();
@@ -51,21 +45,15 @@ public function __construct($endpoint)
->setUrl($url);
}

/**
* @return RequestInterface
*/
public function getRequest()
public function getRequest(): RequestInterface
{
return $this->request;
}

/**
* @param string[] $queryParameters
* @return ResponseInterface
* @throws NetworkException
* @throws ConnectionTimeoutException
*/
public function get(array $queryParameters = array())
public function get(array $queryParameters = []): ResponseInterface
{
$this->request
->setMethod(RequestInterface::REQUEST_METHOD_GET)
@@ -77,11 +65,8 @@ public function get(array $queryParameters = array())

/**
* @param string[] $queryParameters
* @return ResponseInterface
* @throws NetworkException
* @throws ConnectionTimeoutException
*/
public function head(array $queryParameters = array())
public function head(array $queryParameters = []): ResponseInterface
{
$this->request
->setMethod(RequestInterface::REQUEST_METHOD_HEAD)
@@ -91,13 +76,7 @@ public function head(array $queryParameters = array())
return $this->request->getResponse();
}

/**
* @param array $postData
* @return ResponseInterface
* @throws NetworkException
* @throws ConnectionTimeoutException
*/
public function post(array $postData = array())
public function post(array $postData = []): ResponseInterface
{
$this->request
->getMessage()
@@ -108,13 +87,7 @@ public function post(array $postData = array())
return $this->request->getResponse();
}

/**
* @param array $putData
* @return ResponseInterface
* @throws NetworkException
* @throws ConnectionTimeoutException
*/
public function put(array $putData = array())
public function put(array $putData = []): ResponseInterface
{
$this->request
->getMessage()
@@ -125,13 +98,7 @@ public function put(array $putData = array())
return $this->request->getResponse();
}

/**
* @param array $patchData
* @return ResponseInterface
* @throws NetworkException
* @throws ConnectionTimeoutException
*/
public function patch(array $patchData = array())
public function patch(array $patchData = []): ResponseInterface
{
$this->request
->getMessage()
@@ -142,13 +109,7 @@ public function patch(array $patchData = array())
return $this->request->getResponse();
}

/**
* @param string[] $queryParameters
* @return ResponseInterface
* @throws NetworkException
* @throws ConnectionTimeoutException
*/
public function delete(array $queryParameters = array())
public function delete(array $queryParameters = []): ResponseInterface
{
$this->request
->setMethod(RequestInterface::REQUEST_METHOD_DELETE)
17 changes: 8 additions & 9 deletions src/Request/JsonRequest.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<?php

namespace Markenwerk\JsonHttpClient\Request;
declare(strict_types=1);

use Markenwerk\BasicHttpClient\Request\AbstractRequest;
use Markenwerk\BasicHttpClient\Response\ResponseInterface;
use Markenwerk\JsonHttpClient\Response\JsonResponse;
namespace ChromaX\JsonHttpClient\Request;

use ChromaX\BasicHttpClient\Request\AbstractRequest;
use ChromaX\BasicHttpClient\Response\ResponseInterface;
use ChromaX\JsonHttpClient\Response\JsonResponse;

/**
* Class JsonRequest
*
* @package Markenwerk\JsonHttpClient\Request
* @package ChromaX\JsonHttpClient\Request
*/
class JsonRequest extends AbstractRequest
{

/**
* @return ResponseInterface
*/
protected function buildResponse()
protected function buildResponse(): ResponseInterface
{
return new JsonResponse($this);
}
31 changes: 12 additions & 19 deletions src/Request/Message/Body/JsonBody.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
<?php

namespace Markenwerk\JsonHttpClient\Request\Message\Body;
declare(strict_types=1);

use Markenwerk\BasicHttpClient\Exception\HttpRequestMessageException;
use Markenwerk\BasicHttpClient\Request\Message\Body\BodyInterface;
namespace ChromaX\JsonHttpClient\Request\Message\Body;

use ChromaX\BasicHttpClient\Exception\HttpRequestMessageException;
use ChromaX\BasicHttpClient\Request\Message\Body\BodyInterface;

/**
* Class JsonBody
*
* @package Markenwerk\JsonHttpClient\Request\Message\Body
* @package ChromaX\JsonHttpClient\Request\Message\Body
*/
class JsonBody implements BodyInterface
{

/**
* @var array
*/
private $bodyData;
private array $bodyData;

/**
* Body constructor.
*
* @param array $bodyData
*/
public function __construct(array $bodyData)
{
$this->bodyData = $bodyData;
}

/**
* @param resource $curl
* @return $this
* @throws HttpRequestMessageException
*/
public function configureCurl($curl)
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.');
24 changes: 9 additions & 15 deletions src/Response/JsonResponse.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<?php

namespace Markenwerk\JsonHttpClient\Response;
declare(strict_types=1);

use Markenwerk\BasicHttpClient\Exception\HttpResponseException;
use Markenwerk\BasicHttpClient\Response\AbstractResponse;
namespace ChromaX\JsonHttpClient\Response;

use ChromaX\BasicHttpClient\Exception\HttpResponseException;
use ChromaX\BasicHttpClient\Response\AbstractResponse;

/**
* Class JsonResponse
*
* @package Markenwerk\JsonHttpClient\Response
* @package ChromaX\JsonHttpClient\Response
*/
class JsonResponse extends AbstractResponse
{

/**
* @param mixed $body
* @return $this
* @throws HttpResponseException
*/
protected function setBody($body)
protected function setBody(mixed $body): self
{
if ($this->getStatusCode() === 204) {
parent::setBody(null);
@@ -31,11 +28,8 @@ protected function setBody($body)
parent::setBody($body);
return $this;
}

/**
* @return array
*/
public function getBody()

public function getBody(): array
{
return parent::getBody();
}