Skip to content

Commit fff5689

Browse files
committed
refactor(Response): Improve handling of decoded JSON response
- Update 'decoded' property to remove nullable type declaration - Fix json() method to correctly handle decoding of JSON response - Provide debug information about the response in the toArray() method
1 parent f8405b4 commit fff5689

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/Foundation/Response.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ class Response extends \GuzzleHttp\Psr7\Response implements \ArrayAccess
6161

6262
/**
6363
* The decoded JSON response.
64+
*
65+
* @var null|array|scalar
6466
*/
65-
protected ?array $decoded = null;
67+
protected $decoded;
6668

6769
/**
6870
* Provide debug information about the response.
@@ -78,7 +80,7 @@ public function __debugInfo(): array
7880
'status' => $this->status(),
7981
'reason' => $this->reason(),
8082
'body' => $this->body(),
81-
// 'decodedBody' => $this->json(),
83+
'decodedBody' => $this->json(),
8284
]);
8385
}
8486

@@ -126,7 +128,7 @@ public function body(): string
126128
*/
127129
public function json($key = null, $default = null)
128130
{
129-
if (! $this->decoded) {
131+
if (null === $this->decoded) {
130132
$this->decoded = json_decode($this->body(), true);
131133
}
132134

0 commit comments

Comments
 (0)