Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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