Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3661-3691 (lines=31) @@
3658
   *
3659
   * @return string
3660
   */
3661
  public static function rawurldecode($str, $multi_decode = true)
3662
  {
3663
    $str = (string)$str;
3664
3665
    if (!isset($str[0])) {
3666
      return '';
3667
    }
3668
3669
    $pattern = '/%u([0-9a-f]{3,4})/i';
3670
    if (preg_match($pattern, $str)) {
3671
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3672
    }
3673
3674
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3675
3676
    do {
3677
      $str_compare = $str;
3678
3679
      $str = self::fix_simple_utf8(
3680
          rawurldecode(
3681
              self::html_entity_decode(
3682
                  self::to_utf8($str),
3683
                  $flags
3684
              )
3685
          )
3686
      );
3687
3688
    } while ($multi_decode === true && $str_compare !== $str);
3689
3690
    return (string)$str;
3691
  }
3692
3693
  /**
3694
   * alias for "UTF8::remove_bom()"
@@ 6786-6816 (lines=31) @@
6783
   *
6784
   * @return string
6785
   */
6786
  public static function urldecode($str, $multi_decode = true)
6787
  {
6788
    $str = (string)$str;
6789
6790
    if (!isset($str[0])) {
6791
      return '';
6792
    }
6793
6794
    $pattern = '/%u([0-9a-f]{3,4})/i';
6795
    if (preg_match($pattern, $str)) {
6796
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
6797
    }
6798
6799
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6800
6801
    do {
6802
      $str_compare = $str;
6803
6804
      $str = self::fix_simple_utf8(
6805
          urldecode(
6806
              self::html_entity_decode(
6807
                  self::to_utf8($str),
6808
                  $flags
6809
              )
6810
          )
6811
      );
6812
6813
    } while ($multi_decode === true && $str_compare !== $str);
6814
6815
    return (string)$str;
6816
  }
6817
6818
  /**
6819
   * Return a array with "urlencoded"-win1252 -> UTF-8