Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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