Skip to content

Commit

Permalink
Revert "Fix test error"
Browse files Browse the repository at this point in the history
This reverts commit 0683686.
  • Loading branch information
parsilver committed May 15, 2023
1 parent 0f52a38 commit 167934a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Response implements ResponseInterface
protected $jsonDecoded;

/**
* @var string|null
* @var string
*/
protected $content;

Expand All @@ -26,7 +26,7 @@ public function __construct(
protected PsrRequestInterface $request,
protected PsrResponseInterface $response
) {
//
$this->content = $this->response->getBody()->getContents();
}

/**
Expand All @@ -42,10 +42,6 @@ public function statusCode(): int
*/
public function body(): string
{
if (is_null($this->content)) {
$this->content = $this->response->getBody()->getContents();
}

return $this->content;
}

Expand Down Expand Up @@ -73,7 +69,7 @@ public function isSuccessfull(): bool
public function json(?string $key = null): mixed
{
if (is_null($this->jsonDecoded)) {
$this->jsonDecoded = @json_decode($this->body(), true) ?: false;
$this->jsonDecoded = @json_decode($this->content, true) ?: false;
}

if ($this->jsonDecoded === false) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it('should return the psr response', function () {
$response = new Response(
\Mockery::mock(PsrRequestInterface::class),
\Mockery::mock(PsrResponseInterface::class),
\Mockery::mock(PsrResponseInterface::class)
);

expect($response->getPsrResponse())->toBeInstanceOf(PsrResponseInterface::class);
Expand Down

0 comments on commit 167934a

Please sign in to comment.