Code Duplication    Length = 21-22 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 1165-1185 (lines=21) @@
1162
   *
1163
   * @return string
1164
   */
1165
  public static function fix_simple_utf8(string $str): string
1166
  {
1167
    if (!isset($str[0])) {
1168
      return '';
1169
    }
1170
1171
    static $BROKEN_UTF8_TO_UTF8_KEYS_CACHE = null;
1172
    static $BROKEN_UTF8_TO_UTF8_VALUES_CACHE = null;
1173
1174
    if ($BROKEN_UTF8_TO_UTF8_KEYS_CACHE === null) {
1175
1176
      if (self::$BROKEN_UTF8_FIX === null) {
1177
        self::$BROKEN_UTF8_FIX = self::getData('utf8_fix');
1178
      }
1179
1180
      $BROKEN_UTF8_TO_UTF8_KEYS_CACHE = \array_keys(self::$BROKEN_UTF8_FIX);
1181
      $BROKEN_UTF8_TO_UTF8_VALUES_CACHE = \array_values(self::$BROKEN_UTF8_FIX);
1182
    }
1183
1184
    return \str_replace($BROKEN_UTF8_TO_UTF8_KEYS_CACHE, $BROKEN_UTF8_TO_UTF8_VALUES_CACHE, $str);
1185
  }
1186
1187
  /**
1188
   * Fix a double (or multiple) encoded UTF8 string.
@@ 2950-2971 (lines=22) @@
2947
   *
2948
   * @return string
2949
   */
2950
  public static function normalize_msword(string $str): string
2951
  {
2952
    if (!isset($str[0])) {
2953
      return '';
2954
    }
2955
2956
    static $UTF8_MSWORD_KEYS_CACHE = null;
2957
    static $UTF8_MSWORD_VALUES_CACHE = null;
2958
2959
    if ($UTF8_MSWORD_KEYS_CACHE === null) {
2960
2961
2962
      if (self::$UTF8_MSWORD === null) {
2963
        self::$UTF8_MSWORD = self::getData('utf8_msword');
2964
      }
2965
2966
      $UTF8_MSWORD_KEYS_CACHE = \array_keys(self::$UTF8_MSWORD);
2967
      $UTF8_MSWORD_VALUES_CACHE = \array_values(self::$UTF8_MSWORD);
2968
    }
2969
2970
    return \str_replace($UTF8_MSWORD_KEYS_CACHE, $UTF8_MSWORD_VALUES_CACHE, $str);
2971
  }
2972
2973
  /**
2974
   * Normalize the whitespace.