RequestFactory.php
7 months ago
ResponseFactory.php
7 months ago
ServerRequestFactory.php
7 months ago
StreamFactory.php
7 months ago
UploadedFileFactory.php
7 months ago
UriFactory.php
7 months ago
StreamFactory.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Http\Factory\Guzzle; |
| 4 | |
| 5 | use AmeliaVendor\GuzzleHttp\Psr7\Stream; |
| 6 | use AmeliaVendor\GuzzleHttp\Psr7\Utils; |
| 7 | use AmeliaVendor\Psr\Http\Message\StreamFactoryInterface; |
| 8 | use AmeliaVendor\Psr\Http\Message\StreamInterface; |
| 9 | |
| 10 | class StreamFactory implements StreamFactoryInterface |
| 11 | { |
| 12 | public function createStream(string $content = ''): StreamInterface |
| 13 | { |
| 14 | return Utils::streamFor($content); |
| 15 | } |
| 16 | |
| 17 | public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface |
| 18 | { |
| 19 | return $this->createStreamFromResource(Utils::tryFopen($file, $mode)); |
| 20 | } |
| 21 | |
| 22 | public function createStreamFromResource($resource): StreamInterface |
| 23 | { |
| 24 | return new Stream($resource); |
| 25 | } |
| 26 | } |
| 27 |