Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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