| Conditions | 1 |
| Paths | 1 |
| Total Lines | 14 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 1 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | 16 | public function transform( string $segment ): string { |
|
| 18 | |||
| 19 | //clean invalid xml entities ( characters with ascii < 32 and different from 0A, 0D and 09 |
||
| 20 | 16 | $regexpHexEntity = '/&#x(0[0-8BCEF]|1[0-9A-F]|7F);/u'; |
|
| 21 | |||
| 22 | 16 | $regexpEntity = '/&#(0[0-8]|1[1-2]|1[4-9]|2[0-9]|3[0-1]|127);/u'; |
|
| 23 | |||
| 24 | //remove binary chars in some xliff files |
||
| 25 | 16 | $regexpAscii = '/[\x{00}-\x{08}\x{0B}\x{0C}\x{0E}-\x{1F}\x{7F}]/u'; |
|
| 26 | |||
| 27 | 16 | $segment = preg_replace( $regexpAscii, '', $segment ); |
|
| 28 | 16 | $segment = preg_replace( $regexpHexEntity, '', $segment ); |
|
| 29 | |||
| 30 | 16 | return preg_replace( $regexpEntity, '', $segment ); |
|
| 31 | |||
| 34 | } |