Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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