Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3980-4010 (lines=31) @@
3977
   *
3978
   * @return string
3979
   */
3980
  public static function rawurldecode($str, $multi_decode = true)
3981
  {
3982
    $str = (string)$str;
3983
3984
    if (!isset($str[0])) {
3985
      return '';
3986
    }
3987
3988
    $pattern = '/%u([0-9a-f]{3,4})/i';
3989
    if (preg_match($pattern, $str)) {
3990
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3991
    }
3992
3993
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3994
3995
    do {
3996
      $str_compare = $str;
3997
3998
      $str = self::fix_simple_utf8(
3999
          rawurldecode(
4000
              self::html_entity_decode(
4001
                  self::to_utf8($str),
4002
                  $flags
4003
              )
4004
          )
4005
      );
4006
4007
    } while ($multi_decode === true && $str_compare !== $str);
4008
4009
    return (string)$str;
4010
  }
4011
4012
  /**
4013
   * alias for "UTF8::remove_bom()"
@@ 7516-7546 (lines=31) @@
7513
   *
7514
   * @return string
7515
   */
7516
  public static function urldecode($str, $multi_decode = true)
7517
  {
7518
    $str = (string)$str;
7519
7520
    if (!isset($str[0])) {
7521
      return '';
7522
    }
7523
7524
    $pattern = '/%u([0-9a-f]{3,4})/i';
7525
    if (preg_match($pattern, $str)) {
7526
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
7527
    }
7528
7529
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
7530
7531
    do {
7532
      $str_compare = $str;
7533
7534
      $str = self::fix_simple_utf8(
7535
          urldecode(
7536
              self::html_entity_decode(
7537
                  self::to_utf8($str),
7538
                  $flags
7539
              )
7540
          )
7541
      );
7542
7543
    } while ($multi_decode === true && $str_compare !== $str);
7544
7545
    return (string)$str;
7546
  }
7547
7548
  /**
7549
   * Return a array with "urlencoded"-win1252 -> UTF-8