Skip to content
This repository was archived by the owner on Dec 28, 2020. It is now read-only.

Commit 6ea3a08

Browse files
Guard for empty response body.
1 parent 15fcbd3 commit 6ea3a08

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Environment.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ protected function requestAccessToken(): AccessToken
134134
]
135135
]);
136136

137-
if ($response->getStatusCode() == 200) {
138-
$responseData = json_decode($response->getBody());
139-
137+
if ($response->getStatusCode() == 200 && is_object($responseData = json_decode($response->getBody()))) {
140138
return new AccessToken($responseData->access_token, (int) $responseData->expires_in);
141139
}
142140

@@ -167,7 +165,7 @@ public function getRequest(string $endpoint, array $parameters = []): Response
167165
}
168166
}
169167

170-
public function postRequest(string $endpoint, array $data): Response
168+
public function postRequest(string $endpoint, array $data = []): Response
171169
{
172170
try {
173171
$response = $this->httpClient->request('POST', $endpoint, [

0 commit comments

Comments
 (0)