Total Complexity | 3 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | class StringUtil |
||
6 | { |
||
7 | const BOM_UTF8 = "\xEF\xBB\xBF"; |
||
8 | const BOM_UTF16_BE = "\xFE\xFF"; |
||
9 | const BOM_UTF16_LE = "\xFF\xFE"; |
||
10 | const BOM_UTF32_BE = "\x00\x00\xFE\xFF"; |
||
11 | const BOM_UTF32_LE = "\xFF\xFE\x00\x00"; |
||
12 | |||
13 | /** |
||
14 | * Returns whether the given string starts with the given Byte Order Mark. |
||
15 | * |
||
16 | * @param string $input |
||
17 | * @param string $bom |
||
18 | * |
||
19 | * @return bool |
||
20 | */ |
||
21 | 4 | public static function hasBom($input, $bom) |
|
22 | { |
||
23 | 4 | return \strpos($input, $bom) === 0; |
|
24 | } |
||
25 | |||
26 | /** |
||
27 | * Strips a Byte Order Mark from the beginning of a string if it is present. |
||
28 | * |
||
29 | * @param string $input Data to be stripped of its BOM. |
||
30 | * @param string $bom |
||
31 | * |
||
32 | * @return string The stripped input string. |
||
33 | */ |
||
34 | 4 | public static function stripBom($input, $bom) |
|
41 | } |
||
42 | } |
||
43 |