Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
namespace Psr\Http\Message;
4
 
5
interface StreamFactoryInterface
6
{
7
    /**
8
     * Create a new stream from a string.
9
     *
10
     * The stream SHOULD be created with a temporary resource.
11
     *
12
     * @param string $content String content with which to populate the stream.
13
     *
14
     * @return StreamInterface
15
     */
16
    public function createStream(string $content = ''): StreamInterface;
17
 
18
    /**
19
     * Create a stream from an existing file.
20
     *
21
     * The file MUST be opened using the given mode, which may be any mode
22
     * supported by the `fopen` function.
23
     *
24
     * The `$filename` MAY be any string supported by `fopen()`.
25
     *
26
     * @param string $filename Filename or stream URI to use as basis of stream.
27
     * @param string $mode Mode with which to open the underlying filename/stream.
28
     *
29
     * @return StreamInterface
30
     * @throws \RuntimeException If the file cannot be opened.
31
     * @throws \InvalidArgumentException If the mode is invalid.
32
     */
33
    public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface;
34
 
35
    /**
36
     * Create a new stream from an existing resource.
37
     *
38
     * The stream MUST be readable and may be writable.
39
     *
40
     * @param resource $resource PHP resource to use as basis of stream.
41
     *
42
     * @return StreamInterface
43
     */
44
    public function createStreamFromResource($resource): StreamInterface;
45
}