| Conditions | 3 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public static function convert(string $string, string $locale = null, ?string $replaceUnsupportedBy = ''): string |
||
| 12 | { |
||
| 13 | $map = self::DEFAULT_MAP; |
||
| 14 | |||
| 15 | if (null !== $locale) { |
||
| 16 | $locale = \strtolower($locale); |
||
| 17 | $lang = \explode('_', \strtr($locale, ['-' => '_']))[0]; |
||
| 18 | $map = \array_replace($map, (self::SPECIFIC_MAPS[$lang] ?? [])); |
||
| 19 | } |
||
| 20 | |||
| 21 | $asciized = \strtr($string, $map); |
||
| 22 | |||
| 23 | if (null !== $replaceUnsupportedBy) { |
||
| 24 | $asciized = \preg_replace('/[^\x20-\x7E]/u', $replaceUnsupportedBy, $asciized); |
||
| 25 | } |
||
| 26 | |||
| 27 | return $asciized; |
||
| 28 | } |
||
| 866 |