1 | <?php |
||
17 | class StringStream implements StreamInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var string $buffer Stores the string to use |
||
21 | */ |
||
22 | protected $buffer; |
||
23 | |||
24 | /** |
||
25 | * StringStream constructor. |
||
26 | * |
||
27 | * @param string $string |
||
28 | */ |
||
29 | 7 | public function __construct(string $string) |
|
33 | |||
34 | /** |
||
35 | * {@inheritDoc} |
||
36 | * |
||
37 | * @throws \InvalidArgumentException when length parameter is invalid |
||
38 | * @throws StreamException when the stream have been tatly red and read methd is called again |
||
39 | */ |
||
40 | 6 | public function read(int $length): string |
|
66 | |||
67 | /** |
||
68 | * Fake write method, do nothing except return the "writen" length |
||
69 | * |
||
70 | * @param string $string The string to write |
||
71 | * @param int|null $length the number of characters to write |
||
72 | * @return int number of "writen" bytes |
||
73 | * @throws \InvalidArgumentException on invalid length |
||
74 | */ |
||
75 | 13 | public function write(string $string, int $length = null): int |
|
87 | |||
88 | /** |
||
89 | * Close stream connection |
||
90 | * |
||
91 | * @return void |
||
92 | */ |
||
93 | 1 | public function close() |
|
97 | } |
||
98 |