| Conditions | 7 |
| Paths | 8 |
| Total Lines | 28 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 7.5376 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 55 | 7 | public static function utf8_decode($s) |
|
| 56 | { |
||
| 57 | 7 | $s .= ''; |
|
| 58 | 7 | $len = strlen($s); |
|
| 59 | |||
| 60 | 7 | for ($i = 0, $j = 0; $i < $len; ++$i, ++$j) { |
|
| 61 | 7 | switch ($s[$i] & "\xF0") { |
|
| 62 | case "\xC0": |
||
| 63 | case "\xD0": |
||
| 64 | 7 | $c = (ord($s[$i] & "\x1F") << 6) | ord($s[++$i] & "\x3F"); |
|
| 65 | 7 | $s[$j] = $c < 256 ? chr($c) : '?'; |
|
| 66 | 7 | break; |
|
| 67 | |||
| 68 | /** @noinspection PhpMissingBreakStatementInspection */ |
||
| 69 | case "\xF0": |
||
|
|
|||
| 70 | ++$i; |
||
| 71 | 7 | case "\xE0": |
|
| 72 | 5 | $s[$j] = '?'; |
|
| 73 | 5 | $i += 2; |
|
| 74 | 5 | break; |
|
| 75 | |||
| 76 | default: |
||
| 77 | 7 | $s[$j] = $s[$i]; |
|
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | 7 | return substr($s, 0, $j); |
|
| 82 | } |
||
| 83 | } |
||
| 84 |