Total Complexity | 5 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
18 | final class StringStream implements Stream |
||
19 | { |
||
20 | private $resource; |
||
21 | |||
22 | /** |
||
23 | * StringStream constructor. |
||
24 | * |
||
25 | * @param string $data |
||
26 | */ |
||
27 | public function __construct(string $data) |
||
28 | { |
||
29 | $this->resource = fopen('php://memory', 'r+'); |
||
30 | fwrite($this->resource, $data); |
||
|
|||
31 | rewind($this->resource); |
||
32 | } |
||
33 | |||
34 | public function read(int $length): string |
||
48 | } |
||
49 | } |
||
50 |