| Conditions | 4 |
| Paths | 4 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | public function read(int $length): string |
||
| 35 | { |
||
| 36 | if (0 === $length) { |
||
| 37 | return ''; |
||
| 38 | } |
||
| 39 | $data = fread($this->resource, $length); |
||
| 40 | if (!is_string($data)) { |
||
| 41 | throw new \InvalidArgumentException('Cannot stream the data'); |
||
| 42 | } |
||
| 43 | if (mb_strlen($data, '8bit') !== $length) { |
||
| 44 | throw new \InvalidArgumentException(sprintf('Out of range. Expected: %d, read: %d', $length, mb_strlen($data, '8bit'))); |
||
| 45 | } |
||
| 46 | |||
| 47 | return $data; |
||
| 48 | } |
||
| 50 |