Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3767-3797 (lines=31) @@
3764
   *
3765
   * @return string
3766
   */
3767
  public static function rawurldecode($str, $multi_decode = true)
3768
  {
3769
    $str = (string)$str;
3770
3771
    if (!isset($str[0])) {
3772
      return '';
3773
    }
3774
3775
    $pattern = '/%u([0-9a-f]{3,4})/i';
3776
    if (preg_match($pattern, $str)) {
3777
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3778
    }
3779
3780
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3781
3782
    do {
3783
      $str_compare = $str;
3784
3785
      $str = self::fix_simple_utf8(
3786
          rawurldecode(
3787
              self::html_entity_decode(
3788
                  self::to_utf8($str),
3789
                  $flags
3790
              )
3791
          )
3792
      );
3793
3794
    } while ($multi_decode === true && $str_compare !== $str);
3795
3796
    return (string)$str;
3797
  }
3798
3799
  /**
3800
   * alias for "UTF8::remove_bom()"
@@ 7004-7034 (lines=31) @@
7001
   *
7002
   * @return string
7003
   */
7004
  public static function urldecode($str, $multi_decode = true)
7005
  {
7006
    $str = (string)$str;
7007
7008
    if (!isset($str[0])) {
7009
      return '';
7010
    }
7011
7012
    $pattern = '/%u([0-9a-f]{3,4})/i';
7013
    if (preg_match($pattern, $str)) {
7014
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
7015
    }
7016
7017
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
7018
7019
    do {
7020
      $str_compare = $str;
7021
7022
      $str = self::fix_simple_utf8(
7023
          urldecode(
7024
              self::html_entity_decode(
7025
                  self::to_utf8($str),
7026
                  $flags
7027
              )
7028
          )
7029
      );
7030
7031
    } while ($multi_decode === true && $str_compare !== $str);
7032
7033
    return (string)$str;
7034
  }
7035
7036
  /**
7037
   * Return a array with "urlencoded"-win1252 -> UTF-8