-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathStreamFactory.php
More file actions
28 lines (23 loc) · 754 Bytes
/
StreamFactory.php
File metadata and controls
28 lines (23 loc) · 754 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
<?php
namespace React\Filesystem\Stream;
use React\Filesystem\AdapterInterface;
class StreamFactory
{
/**
* @param string $path
* @param mixed $fileDescriptor
* @param int $flags
* @param AdapterInterface $filesystem
* @return DuplexStream|ReadableStream|WritableStream
*/
public static function create($path, $fileDescriptor, $flags, AdapterInterface $filesystem)
{
if (strpos($flags, 'r') !== false) {
return new ReadableStream($path, $fileDescriptor, $filesystem);
}
if (strpos($flags, 'w') !== false) {
return new WritableStream($path, $fileDescriptor, $filesystem);
}
return new DuplexStream($path, $fileDescriptor, $filesystem);
}
}