Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3702-3732 (lines=31) @@
3699
   *
3700
   * @return string
3701
   */
3702
  public static function rawurldecode($str, $multi_decode = true)
3703
  {
3704
    $str = (string)$str;
3705
3706
    if (!isset($str[0])) {
3707
      return '';
3708
    }
3709
3710
    $pattern = '/%u([0-9a-f]{3,4})/i';
3711
    if (preg_match($pattern, $str)) {
3712
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3713
    }
3714
3715
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3716
3717
    do {
3718
      $str_compare = $str;
3719
3720
      $str = self::fix_simple_utf8(
3721
          rawurldecode(
3722
              self::html_entity_decode(
3723
                  self::to_utf8($str),
3724
                  $flags
3725
              )
3726
          )
3727
      );
3728
3729
    } while ($multi_decode === true && $str_compare !== $str);
3730
3731
    return (string)$str;
3732
  }
3733
3734
  /**
3735
   * alias for "UTF8::remove_bom()"
@@ 6882-6912 (lines=31) @@
6879
   *
6880
   * @return string
6881
   */
6882
  public static function urldecode($str, $multi_decode = true)
6883
  {
6884
    $str = (string)$str;
6885
6886
    if (!isset($str[0])) {
6887
      return '';
6888
    }
6889
6890
    $pattern = '/%u([0-9a-f]{3,4})/i';
6891
    if (preg_match($pattern, $str)) {
6892
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
6893
    }
6894
6895
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6896
6897
    do {
6898
      $str_compare = $str;
6899
6900
      $str = self::fix_simple_utf8(
6901
          urldecode(
6902
              self::html_entity_decode(
6903
                  self::to_utf8($str),
6904
                  $flags
6905
              )
6906
          )
6907
      );
6908
6909
    } while ($multi_decode === true && $str_compare !== $str);
6910
6911
    return (string)$str;
6912
  }
6913
6914
  /**
6915
   * Return a array with "urlencoded"-win1252 -> UTF-8