| Conditions | 4 |
| Paths | 6 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 47 | 2 | public function readStream(int $d_size = 1024): string |
|
| 48 | { |
||
| 49 | 2 | $s = $this->stream; |
|
| 50 | 2 | $r = $this->stream['buffer']; |
|
| 51 | |||
| 52 | 2 | $s['buffer'] = ''; |
|
| 53 | 2 | if ($s['size']) { |
|
| 54 | 2 | $d_size = min($d_size, $this->stream['size'] - $this->stream['pos']); |
|
| 55 | } |
||
| 56 | |||
| 57 | 2 | if ('data' == $this->stream['type']) { |
|
| 58 | 2 | if ($d_size > 0) { |
|
| 59 | 2 | $d = substr($this->stream['data'], $s['pos'], $d_size); |
|
| 60 | } else { |
||
| 61 | 2 | $d = ''; |
|
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | 2 | $s['pos'] += \strlen($d); |
|
|
|
|||
| 66 | |||
| 67 | 2 | $this->stream = $s; |
|
| 68 | |||
| 69 | 2 | return $r.$d; |
|
| 70 | } |
||
| 72 |