diff --git a/composer.json b/composer.json index 0a24362..d980be3 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "codeinc/psr7-responses", - "version": "1.4.0", + "version": "1.4.1", "description": "A collection of PSR-7 responses", "homepage": "https://github.com/CodeIncHQ/Psr7Responses", "type": "library", diff --git a/src/StreamResponse.php b/src/StreamResponse.php index 614ec4c..cf929c0 100644 --- a/src/StreamResponse.php +++ b/src/StreamResponse.php @@ -23,6 +23,7 @@ namespace CodeInc\Psr7Responses; use GuzzleHttp\Psr7\Response; use function GuzzleHttp\Psr7\stream_for; +use Psr\Http\Message\StreamInterface; /** @@ -36,10 +37,15 @@ class StreamResponse extends Response { /** - * @var \GuzzleHttp\Psr7\Stream + * @var StreamInterface */ private $stream; + /** + * @var mixed + */ + private $rawResource; + /** * @var null|string */ @@ -77,6 +83,7 @@ public function __construct($resource, ?string $charset = null, ?int $contentLen ?string $fileName = null, bool $asAttachment = false, int $status = 200, array $headers = [], string $version = '1.1', ?string $reason = null) { + $this->rawResource = $resource; $this->stream = stream_for($resource); $this->charset = $charset; $this->contentLength = $contentLength; @@ -99,15 +106,25 @@ public function __construct($resource, ?string $charset = null, ?int $contentLen } /** - * Returns the stream. + * Returns the resource wrapped into a stream. * - * @return \GuzzleHttp\Psr7\Stream + * @return StreamInterface */ - public function getStream():\GuzzleHttp\Psr7\Stream + public function getStream():StreamInterface { return $this->stream; } + /** + * Returns the raw resource as passed to the constructor. + * + * @return mixed + */ + public function getRawResource() + { + return $this->rawResource; + } + /** * Returns the mime type if set or null. *