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