| Conditions | 3 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | 2 | public function processDecode(string $content): string |
|
| 35 | { |
||
| 36 | 2 | $partialData = $content; |
|
| 37 | 2 | $cleared = ''; |
|
| 38 | do { |
||
| 39 | 2 | if (preg_match('#^(([0-9a-fA-F]+)\r\n)(.*)#m', $partialData, $matches)) { |
|
| 40 | 2 | $segmentLength = hexdec($matches[2]); |
|
| 41 | // skip bytes defined as chunk size and get next with length of chunk size |
||
| 42 | 2 | $chunk = mb_substr($partialData, mb_strlen($matches[1]), intval($segmentLength)); |
|
| 43 | 2 | $cleared .= $chunk; |
|
| 44 | // remove bytes with chunk size, chunk itself and ending crlf |
||
| 45 | 2 | $partialData = mb_substr($partialData, mb_strlen($matches[1]) + mb_strlen($chunk) + mb_strlen(Protocols\Http::DELIMITER)); |
|
| 46 | } else { |
||
| 47 | // @codeCoverageIgnoreStart |
||
| 48 | $segmentLength = 0; |
||
| 49 | } |
||
| 50 | // @codeCoverageIgnoreEnd |
||
| 51 | 2 | } while (0 < $segmentLength); |
|
| 52 | 2 | $content = $cleared; |
|
| 53 | 2 | return $content; |
|
| 54 | } |
||
| 56 |