1 | <?php |
||
16 | class ResourceStream implements StreamInterface |
||
17 | { |
||
18 | protected $stream; |
||
19 | |||
20 | /** |
||
21 | * ResourceStream constructor. |
||
22 | * |
||
23 | * @param $stream |
||
24 | */ |
||
25 | 20 | public function __construct($stream) |
|
39 | |||
40 | /** |
||
41 | * @param int $length |
||
42 | * @return string |
||
43 | * @throws \RouterOS\Exceptions\StreamException |
||
44 | * @throws \InvalidArgumentException |
||
45 | */ |
||
46 | 17 | public function read(int $length): string |
|
61 | |||
62 | /** |
||
63 | * Writes a string to a stream |
||
64 | * |
||
65 | * Write $length bytes of string, if not mentioned, write all the string |
||
66 | * Must be binary safe (as fread). |
||
67 | * if $length is greater than string length, write all string and return number of writen bytes |
||
68 | * if $length os smaller than string length, remaining bytes are losts. |
||
69 | * |
||
70 | * @param string $string |
||
71 | * @param int|null $length the numer of bytes to read |
||
72 | * @return int the number of written bytes |
||
73 | * @throws \RouterOS\Exceptions\StreamException |
||
74 | */ |
||
75 | 15 | public function write(string $string, int $length = null): int |
|
90 | |||
91 | /** |
||
92 | * Close stream connection |
||
93 | * |
||
94 | * @return void |
||
95 | * @throws \RouterOS\Exceptions\StreamException |
||
96 | */ |
||
97 | 2 | public function close() |
|
110 | } |
||
111 |