Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6190-6220 (lines=31) @@
6187
   *
6188
   * @return string
6189
   */
6190
  public static function urldecode($str, $multi_decode = true)
6191
  {
6192
    $str = (string)$str;
6193
6194
    if (!isset($str[0])) {
6195
      return '';
6196
    }
6197
6198
    $pattern = '/%u([0-9a-f]{3,4})/i';
6199
    if (preg_match($pattern, $str)) {
6200
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
6201
    }
6202
6203
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6204
6205
    do {
6206
      $str_compare = $str;
6207
6208
      $str = self::fix_simple_utf8(
6209
          urldecode(
6210
              self::html_entity_decode(
6211
                  self::to_utf8($str),
6212
                  $flags
6213
              )
6214
          )
6215
      );
6216
6217
    } while ($multi_decode === true && $str_compare !== $str);
6218
6219
    return (string)$str;
6220
  }
6221
6222
  /**
6223
   * Multi decode html entity & fix urlencoded-win1252-chars.
@@ 6241-6271 (lines=31) @@
6238
   *
6239
   * @return string
6240
   */
6241
  public static function rawurldecode($str, $multi_decode = true)
6242
  {
6243
    $str = (string)$str;
6244
6245
    if (!isset($str[0])) {
6246
      return '';
6247
    }
6248
6249
    $pattern = '/%u([0-9a-f]{3,4})/i';
6250
    if (preg_match($pattern, $str)) {
6251
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
6252
    }
6253
6254
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6255
6256
    do {
6257
      $str_compare = $str;
6258
6259
      $str = self::fix_simple_utf8(
6260
          rawurldecode(
6261
              self::html_entity_decode(
6262
                  self::to_utf8($str),
6263
                  $flags
6264
              )
6265
          )
6266
      );
6267
6268
    } while ($multi_decode === true && $str_compare !== $str);
6269
6270
    return (string)$str;
6271
  }
6272
6273
  /**
6274
   * Return a array with "urlencoded"-win1252 -> UTF-8