This repository has been archived by the owner on Feb 5, 2019. It is now read-only.
/
StreamResponse.php
70 lines (66 loc) · 2.26 KB
/
StreamResponse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
//
// +---------------------------------------------------------------------+
// | CODE INC. SOURCE CODE |
// +---------------------------------------------------------------------+
// | Copyright (c) 2017 - Code Inc. SAS - All Rights Reserved. |
// | Visit https://www.codeinc.fr for more information about licensing. |
// +---------------------------------------------------------------------+
// | NOTICE: All information contained herein is, and remains the |
// | property of Code Inc. SAS. The intellectual and technical concepts |
// | contained herein are proprietary to Code Inc. SAS are protected by |
// | trade secret or copyright law. Dissemination of this information or |
// | reproduction of this material is strictly forbidden unless prior |
// | written permission is obtained from Code Inc. SAS. |
// +---------------------------------------------------------------------+
//
// Author: Joan Fabrégat <joan@codeinc.fr>
// Date: 23/02/2018
// Time: 19:15
// Project: Psr7Responses
//
declare(strict_types = 1);
namespace CodeInc\Psr7Responses;
use GuzzleHttp\Psr7\Response;
use function GuzzleHttp\Psr7\stream_for;
use Psr\Http\Message\StreamInterface;
/**
* Class StreamResponse
*
* @package CodeInc\Psr7Responses
* @author Joan Fabrégat <joan@codeinc.fr>
* @license MIT <https://github.com/CodeIncHQ/Psr7Responses/blob/master/LICENSE>
* @link https://github.com/CodeIncHQ/Psr7Responses
* @version 2
*/
class StreamResponse extends Response
{
/**
* @var StreamInterface
*/
private $stream;
/**
* StreamResponse constructor.
*
* @param StreamInterface $stream
* @param int $code
* @param string $reasonPhrase
* @param array $headers
* @param string $version
*/
public function __construct(StreamInterface $stream, int $code = 200, string $reasonPhrase = '',
array $headers = [], string $version = '1.1')
{
$this->stream = $stream;
parent::__construct($code, $headers, $stream, $version, $reasonPhrase);
}
/**
* Returns the resource wrapped into a stream.
*
* @return StreamInterface
*/
public function getStream():StreamInterface
{
return $this->stream;
}
}