Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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