Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
Merge pull request #13 from CodeIncHQ/1.x
Browse files Browse the repository at this point in the history
v1.4.1
  • Loading branch information
Joan Fabrégat authored Jul 27, 2018
2 parents 5bd25a0 + f2b65a9 commit 3a32d4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
25 changes: 21 additions & 4 deletions src/StreamResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace CodeInc\Psr7Responses;
use GuzzleHttp\Psr7\Response;
use function GuzzleHttp\Psr7\stream_for;
use Psr\Http\Message\StreamInterface;


/**
Expand All @@ -36,10 +37,15 @@
class StreamResponse extends Response
{
/**
* @var \GuzzleHttp\Psr7\Stream
* @var StreamInterface
*/
private $stream;

/**
* @var mixed
*/
private $rawResource;

/**
* @var null|string
*/
Expand Down Expand Up @@ -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;
Expand All @@ -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.
*
Expand Down

0 comments on commit 3a32d4b

Please sign in to comment.