Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
15 | public function write($target, string $buffer, int $length = null): int |
||
16 | { |
||
17 | $length = $length ?? mb_strlen($buffer, '8bit'); |
||
18 | |||
19 | $written = 0; |
||
20 | while ($written < $length) { |
||
21 | $chunk = mb_substr($buffer, $written, $length, '8bit'); |
||
22 | $byteCount = fwrite($target, $chunk, $length); |
||
23 | |||
24 | if (!$byteCount) { |
||
25 | break; |
||
26 | } |
||
27 | |||
28 | $written += $byteCount; |
||
29 | } |
||
30 | |||
31 | return $written; |
||
32 | } |
||
33 | } |
||
34 |