Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge b4f84d6 into 1059856
Browse files Browse the repository at this point in the history
  • Loading branch information
mavimo committed Feb 14, 2019
2 parents 1059856 + b4f84d6 commit 4711114
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/LooplineSystems/CloseIoApiWrapper/CloseIoResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ public function getHeaders(): array
*/
private function decodeBody(): void
{
if (empty($this->body) || $this->body === null) {
$this->decodedBody = [];

return;
}

$this->decodedBody = json_decode($this->body, true);

if (json_last_error() !== JSON_ERROR_NONE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testGetters(): void
/**
* @dataProvider getDecodedBodyDataProvider
*/
public function testGetDecodedBody(string $body, array $expectedDecodedBody): void
public function testGetDecodedBody(?string $body, array $expectedDecodedBody): void
{
$response = new CloseIoResponse(new CloseIoRequest('GET', '/foo/'), 200, $body);

Expand All @@ -47,6 +47,8 @@ public function getDecodedBodyDataProvider(): array
return [
['{"foo":"bar"}', ['foo' => 'bar']],
['false', []],
['', []],
[null, []],
];
}

Expand Down

0 comments on commit 4711114

Please sign in to comment.