| Conditions | 6 |
| Paths | 6 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 6.6829 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 17 | public function detectUTFEncoding(string $str): ?string |
|
| 20 | { |
||
| 21 | 17 | switch (substr($str, 0, 2)) { |
|
| 22 | 17 | case UTF16_BIG_ENDIAN_BOM: |
|
| 23 | return 'UTF-16BE'; |
||
| 24 | 17 | case UTF16_LITTLE_ENDIAN_BOM: |
|
| 25 | 1 | return 'UTF-16LE'; |
|
| 26 | } |
||
| 27 | |||
| 28 | 16 | switch (substr($str, 0, 3)) { |
|
| 29 | 16 | case UTF8_BOM: |
|
| 30 | return 'UTF-8'; |
||
| 31 | } |
||
| 32 | |||
| 33 | 16 | switch (substr($str, 0, 4)) { |
|
| 34 | 16 | case UTF32_BIG_ENDIAN_BOM: |
|
| 35 | return 'UTF-32BE'; |
||
| 36 | 16 | case UTF32_LITTLE_ENDIAN_BOM: |
|
| 37 | return 'UTF-32LE'; |
||
| 38 | } |
||
| 39 | |||
| 40 | 16 | return null; |
|
| 41 | } |
||
| 43 |