File tree Expand file tree Collapse file tree 4 files changed +8
-10
lines changed
Expand file tree Collapse file tree 4 files changed +8
-10
lines changed Original file line number Diff line number Diff 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 ()
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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 ' ]) ||
Original file line number Diff line number Diff 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 );
You can’t perform that action at this time.
0 commit comments