Conditions | 5 |
Paths | 4 |
Total Lines | 32 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
2288 | 46 | public static function fix_simple_utf8(string $str): string |
|
2289 | { |
||
2290 | 46 | if ($str === '') { |
|
2291 | 4 | return ''; |
|
2292 | } |
||
2293 | |||
2294 | /** |
||
2295 | * @psalm-suppress ImpureStaticVariable |
||
2296 | * |
||
2297 | * @var array<mixed>|null |
||
2298 | */ |
||
2299 | 46 | static $BROKEN_UTF8_TO_UTF8_KEYS_CACHE = null; |
|
2300 | |||
2301 | /** |
||
2302 | * @psalm-suppress ImpureStaticVariable |
||
2303 | * |
||
2304 | * @var array<mixed>|null |
||
2305 | */ |
||
2306 | 46 | static $BROKEN_UTF8_TO_UTF8_VALUES_CACHE = null; |
|
2307 | |||
2308 | 46 | if ($BROKEN_UTF8_TO_UTF8_KEYS_CACHE === null) { |
|
2309 | 1 | if (self::$BROKEN_UTF8_FIX === null) { |
|
2310 | 1 | self::$BROKEN_UTF8_FIX = self::getData('utf8_fix'); |
|
2311 | } |
||
2312 | |||
2313 | 1 | $BROKEN_UTF8_TO_UTF8_KEYS_CACHE = \array_keys(self::$BROKEN_UTF8_FIX ?: []); |
|
2314 | 1 | $BROKEN_UTF8_TO_UTF8_VALUES_CACHE = self::$BROKEN_UTF8_FIX; |
|
2315 | } |
||
2316 | |||
2317 | \assert(\is_array($BROKEN_UTF8_TO_UTF8_VALUES_CACHE)); |
||
2318 | |||
2319 | 46 | return \str_replace($BROKEN_UTF8_TO_UTF8_KEYS_CACHE, $BROKEN_UTF8_TO_UTF8_VALUES_CACHE, $str); |
|
2320 | } |
||
13665 |