| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public static function detect(string $string): string |
||
| 21 | { |
||
| 22 | $encoding = mb_detect_encoding($string, null, true); |
||
| 23 | |||
| 24 | if ($encoding === false) { |
||
| 25 | throw new RuntimeException( |
||
| 26 | \Safe\sprintf( |
||
| 27 | 'Coulnd\'t detect encoding of string:' . PHP_EOL . '%s', |
||
| 28 | $string |
||
| 29 | ) |
||
| 30 | ); |
||
| 31 | } |
||
| 32 | |||
| 33 | return $encoding; |
||
| 34 | } |
||
| 36 |