Skip to content

Commit 94b713f

Browse files
committed
Fix static code analysis issues
1 parent 238d04d commit 94b713f

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

src/Api/BaseClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private function logMessage(Message $message)
138138
/**
139139
* Parse the body of a JSON response.
140140
*/
141-
private function parseResponse(ResponseInterface $response = null): array
141+
private function parseResponse(ResponseInterface $response = null)
142142
{
143143
$body = $response
144144
? (string) $response->getBody()

src/Api/Exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private static function createExceptionMessage(
106106

107107
try {
108108
$result = guzzle_json_decode((string) $response->getBody(), true);
109-
if (isset($result['message'])) {
109+
if (\is_array($result) && isset($result['message'])) {
110110
return $result['message'];
111111
}
112112
} catch (\InvalidArgumentException $e) {

src/Api/Message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function createFromString(string $json): self
8181
{
8282
$data = guzzle_json_decode($json, true);
8383

84-
if (
84+
if (!\is_array($data) ||
8585
!isset($data['api']) ||
8686
!isset($data['request']) ||
8787
!isset($data['response']) ||

src/Api/Requester.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,11 @@ private function createCustomException(ClientException $exception): Exception
8282
{
8383
$errorId = '';
8484
$response = $exception->getResponse();
85-
if ($response) {
86-
try {
87-
$data = guzzle_json_decode((string) $response->getBody(), true);
88-
$errorId = (string) $data['sys']['id'] ?? '';
89-
} catch (InvalidArgumentException $invalidArgumentException) {
90-
$errorId = 'InvalidResponseBody';
91-
}
85+
try {
86+
$data = guzzle_json_decode((string) $response->getBody(), true);
87+
$errorId = (\is_array($data) && (string) $data['sys']['id']) ? $data['sys']['id'] : '';
88+
} catch (InvalidArgumentException $invalidArgumentException) {
89+
$errorId = 'InvalidResponseBody';
9290
}
9391

9492
$exceptionClass = $this->getExceptionClass($errorId);

0 commit comments

Comments
 (0)