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()"
@@ 6744-6774 (lines=31) @@
6741
   *
6742
   * @return string
6743
   */
6744
  public static function urldecode($str, $multi_decode = true)
6745
  {
6746
    $str = (string)$str;
6747
6748
    if (!isset($str[0])) {
6749
      return '';
6750
    }
6751
6752
    $pattern = '/%u([0-9a-f]{3,4})/i';
6753
    if (preg_match($pattern, $str)) {
6754
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
6755
    }
6756
6757
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6758
6759
    do {
6760
      $str_compare = $str;
6761
6762
      $str = self::fix_simple_utf8(
6763
          urldecode(
6764
              self::html_entity_decode(
6765
                  self::to_utf8($str),
6766
                  $flags
6767
              )
6768
          )
6769
      );
6770
6771
    } while ($multi_decode === true && $str_compare !== $str);
6772
6773
    return (string)$str;
6774
  }
6775
6776
  /**
6777
   * Return a array with "urlencoded"-win1252 -> UTF-8