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

Check for rewind_body method #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,14 @@ private function formatUrl($url, $method = 'get')
private function parseResponse(Response $response)
{
try {
Psr7\rewind_body($response);

$json = json_decode($response->getBody()->getContents(), true);
if (method_exists(Psr7::class, 'rewind_body')) {
Psr7\rewind_body($response);
$json = json_decode($response->getBody()->getContents(), true);
} else {
$body = $response->getBody();
$body->seek(0);
$json = json_decode($body->getContents(), true);
}

return data_get($json, 'data');
} catch (\RuntimeException $e) {
Expand Down