-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
139 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
parameters: | ||
level: 2 | ||
level: 3 | ||
paths: | ||
- src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Storyblok; | ||
|
||
use Psr\Http\Message\StreamInterface; | ||
|
||
class Response | ||
{ | ||
public $httpResponseBody; | ||
|
||
public $httpResponseCode; | ||
|
||
public $httpResponseHeaders; | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getBody() | ||
{ | ||
return $this->httpResponseBody; | ||
} | ||
|
||
/** | ||
* @param mixed $httpResponseBody | ||
* | ||
* @return Response | ||
*/ | ||
public function setBody($httpResponseBody) | ||
{ | ||
$this->httpResponseBody = $httpResponseBody; | ||
|
||
return $this; | ||
} | ||
|
||
public function setBodyFromStreamInterface(StreamInterface $body): self | ||
{ | ||
$data = (string) $body; | ||
$jsonResponseData = (array) json_decode($data, true); | ||
// return response data as json if possible, raw if not | ||
$this->httpResponseBody = $data && empty($jsonResponseData) ? $data : $jsonResponseData; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return null|int | ||
*/ | ||
public function getCode() | ||
{ | ||
return $this->httpResponseCode; | ||
} | ||
|
||
/** | ||
* @param mixed $httpResponseCode | ||
* | ||
* @return Response | ||
*/ | ||
public function setCode($httpResponseCode) | ||
{ | ||
$this->httpResponseCode = $httpResponseCode; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getHeaders() | ||
{ | ||
return $this->httpResponseHeaders; | ||
} | ||
|
||
/** | ||
* @param mixed $httpResponseHeaders | ||
* | ||
* @return Response | ||
*/ | ||
public function setHeaders($httpResponseHeaders) | ||
{ | ||
$this->httpResponseHeaders = $httpResponseHeaders; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters