-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamFactory.php
More file actions
35 lines (28 loc) · 891 Bytes
/
StreamFactory.php
File metadata and controls
35 lines (28 loc) · 891 Bytes
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
<?php declare(strict_types=1);
/*
* This file is part of Polymorphine/Message package.
*
* (c) Shudd3r <q3.shudder@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Polymorphine\Message\Factory;
use Polymorphine\Message\Stream;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\StreamInterface;
class StreamFactory implements StreamFactoryInterface
{
public function createStream(string $content = ''): StreamInterface
{
return Stream::fromBodyString($content);
}
public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
{
return Stream::fromResourceUri($filename, $mode);
}
public function createStreamFromResource($resource): StreamInterface
{
return new Stream($resource);
}
}