Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3664-3694 (lines=31) @@
3661
   *
3662
   * @return string
3663
   */
3664
  public static function rawurldecode($str, $multi_decode = true)
3665
  {
3666
    $str = (string)$str;
3667
3668
    if (!isset($str[0])) {
3669
      return '';
3670
    }
3671
3672
    $pattern = '/%u([0-9a-f]{3,4})/i';
3673
    if (preg_match($pattern, $str)) {
3674
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3675
    }
3676
3677
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3678
3679
    do {
3680
      $str_compare = $str;
3681
3682
      $str = self::fix_simple_utf8(
3683
          rawurldecode(
3684
              self::html_entity_decode(
3685
                  self::to_utf8($str),
3686
                  $flags
3687
              )
3688
          )
3689
      );
3690
3691
    } while ($multi_decode === true && $str_compare !== $str);
3692
3693
    return (string)$str;
3694
  }
3695
3696
  /**
3697
   * alias for "UTF8::remove_bom()"
@@ 6760-6790 (lines=31) @@
6757
   *
6758
   * @return string
6759
   */
6760
  public static function urldecode($str, $multi_decode = true)
6761
  {
6762
    $str = (string)$str;
6763
6764
    if (!isset($str[0])) {
6765
      return '';
6766
    }
6767
6768
    $pattern = '/%u([0-9a-f]{3,4})/i';
6769
    if (preg_match($pattern, $str)) {
6770
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
6771
    }
6772
6773
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6774
6775
    do {
6776
      $str_compare = $str;
6777
6778
      $str = self::fix_simple_utf8(
6779
          urldecode(
6780
              self::html_entity_decode(
6781
                  self::to_utf8($str),
6782
                  $flags
6783
              )
6784
          )
6785
      );
6786
6787
    } while ($multi_decode === true && $str_compare !== $str);
6788
6789
    return (string)$str;
6790
  }
6791
6792
  /**
6793
   * Return a array with "urlencoded"-win1252 -> UTF-8