Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3888-3918 (lines=31) @@
3885
   *
3886
   * @return string
3887
   */
3888
  public static function rawurldecode($str, $multi_decode = true)
3889
  {
3890
    $str = (string)$str;
3891
3892
    if (!isset($str[0])) {
3893
      return '';
3894
    }
3895
3896
    $pattern = '/%u([0-9a-f]{3,4})/i';
3897
    if (preg_match($pattern, $str)) {
3898
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3899
    }
3900
3901
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3902
3903
    do {
3904
      $str_compare = $str;
3905
3906
      $str = self::fix_simple_utf8(
3907
          rawurldecode(
3908
              self::html_entity_decode(
3909
                  self::to_utf8($str),
3910
                  $flags
3911
              )
3912
          )
3913
      );
3914
3915
    } while ($multi_decode === true && $str_compare !== $str);
3916
3917
    return (string)$str;
3918
  }
3919
3920
  /**
3921
   * alias for "UTF8::remove_bom()"
@@ 7428-7458 (lines=31) @@
7425
   *
7426
   * @return string
7427
   */
7428
  public static function urldecode($str, $multi_decode = true)
7429
  {
7430
    $str = (string)$str;
7431
7432
    if (!isset($str[0])) {
7433
      return '';
7434
    }
7435
7436
    $pattern = '/%u([0-9a-f]{3,4})/i';
7437
    if (preg_match($pattern, $str)) {
7438
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
7439
    }
7440
7441
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
7442
7443
    do {
7444
      $str_compare = $str;
7445
7446
      $str = self::fix_simple_utf8(
7447
          urldecode(
7448
              self::html_entity_decode(
7449
                  self::to_utf8($str),
7450
                  $flags
7451
              )
7452
          )
7453
      );
7454
7455
    } while ($multi_decode === true && $str_compare !== $str);
7456
7457
    return (string)$str;
7458
  }
7459
7460
  /**
7461
   * Return a array with "urlencoded"-win1252 -> UTF-8