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()"
@@ 7510-7540 (lines=31) @@
7507
   *
7508
   * @return string
7509
   */
7510
  public static function urldecode($str, $multi_decode = true)
7511
  {
7512
    $str = (string)$str;
7513
7514
    if (!isset($str[0])) {
7515
      return '';
7516
    }
7517
7518
    $pattern = '/%u([0-9a-f]{3,4})/i';
7519
    if (preg_match($pattern, $str)) {
7520
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
7521
    }
7522
7523
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
7524
7525
    do {
7526
      $str_compare = $str;
7527
7528
      $str = self::fix_simple_utf8(
7529
          urldecode(
7530
              self::html_entity_decode(
7531
                  self::to_utf8($str),
7532
                  $flags
7533
              )
7534
          )
7535
      );
7536
7537
    } while ($multi_decode === true && $str_compare !== $str);
7538
7539
    return (string)$str;
7540
  }
7541
7542
  /**
7543
   * Return a array with "urlencoded"-win1252 -> UTF-8