Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3989-4019 (lines=31) @@
3986
   *
3987
   * @return string
3988
   */
3989
  public static function rawurldecode($str, $multi_decode = true)
3990
  {
3991
    $str = (string)$str;
3992
3993
    if (!isset($str[0])) {
3994
      return '';
3995
    }
3996
3997
    $pattern = '/%u([0-9a-f]{3,4})/i';
3998
    if (preg_match($pattern, $str)) {
3999
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
4000
    }
4001
4002
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
4003
4004
    do {
4005
      $str_compare = $str;
4006
4007
      $str = self::fix_simple_utf8(
4008
          rawurldecode(
4009
              self::html_entity_decode(
4010
                  self::to_utf8($str),
4011
                  $flags
4012
              )
4013
          )
4014
      );
4015
4016
    } while ($multi_decode === true && $str_compare !== $str);
4017
4018
    return (string)$str;
4019
  }
4020
4021
  /**
4022
   * alias for "UTF8::remove_bom()"
@@ 7537-7567 (lines=31) @@
7534
   *
7535
   * @return string
7536
   */
7537
  public static function urldecode($str, $multi_decode = true)
7538
  {
7539
    $str = (string)$str;
7540
7541
    if (!isset($str[0])) {
7542
      return '';
7543
    }
7544
7545
    $pattern = '/%u([0-9a-f]{3,4})/i';
7546
    if (preg_match($pattern, $str)) {
7547
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
7548
    }
7549
7550
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
7551
7552
    do {
7553
      $str_compare = $str;
7554
7555
      $str = self::fix_simple_utf8(
7556
          urldecode(
7557
              self::html_entity_decode(
7558
                  self::to_utf8($str),
7559
                  $flags
7560
              )
7561
          )
7562
      );
7563
7564
    } while ($multi_decode === true && $str_compare !== $str);
7565
7566
    return (string)$str;
7567
  }
7568
7569
  /**
7570
   * Return a array with "urlencoded"-win1252 -> UTF-8