|null */ private static ?array $encodings = null; public static function clean(string $value): string { if ($value === '' || mb_check_encoding($value, 'UTF-8')) { return $value; } return mb_convert_encoding($value, 'UTF-8', self::encodings()); } /** * @return list */ private static function encodings(): array { if (self::$encodings === null) { self::$encodings = mb_list_encodings(); } return self::$encodings; } }