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.
@@ 2946-2967 (lines=22) @@
2943
   *
2944
   * @return string
2945
   */
2946
  public static function normalize_msword(string $str): string
2947
  {
2948
    if (!isset($str[0])) {
2949
      return '';
2950
    }
2951
2952
    static $UTF8_MSWORD_KEYS_CACHE = null;
2953
    static $UTF8_MSWORD_VALUES_CACHE = null;
2954
2955
    if ($UTF8_MSWORD_KEYS_CACHE === null) {
2956
2957
2958
      if (self::$UTF8_MSWORD === null) {
2959
        self::$UTF8_MSWORD = self::getData('utf8_msword');
2960
      }
2961
2962
      $UTF8_MSWORD_KEYS_CACHE = \array_keys(self::$UTF8_MSWORD);
2963
      $UTF8_MSWORD_VALUES_CACHE = \array_values(self::$UTF8_MSWORD);
2964
    }
2965
2966
    return \str_replace($UTF8_MSWORD_KEYS_CACHE, $UTF8_MSWORD_VALUES_CACHE, $str);
2967
  }
2968
2969
  /**
2970
   * Normalize the whitespace.