Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3921-3951 (lines=31) @@
3918
   *
3919
   * @return string
3920
   */
3921
  public static function rawurldecode($str, $multi_decode = true)
3922
  {
3923
    $str = (string)$str;
3924
3925
    if (!isset($str[0])) {
3926
      return '';
3927
    }
3928
3929
    $pattern = '/%u([0-9a-f]{3,4})/i';
3930
    if (preg_match($pattern, $str)) {
3931
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3932
    }
3933
3934
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3935
3936
    do {
3937
      $str_compare = $str;
3938
3939
      $str = self::fix_simple_utf8(
3940
          rawurldecode(
3941
              self::html_entity_decode(
3942
                  self::to_utf8($str),
3943
                  $flags
3944
              )
3945
          )
3946
      );
3947
3948
    } while ($multi_decode === true && $str_compare !== $str);
3949
3950
    return (string)$str;
3951
  }
3952
3953
  /**
3954
   * alias for "UTF8::remove_bom()"
@@ 7460-7490 (lines=31) @@
7457
   *
7458
   * @return string
7459
   */
7460
  public static function urldecode($str, $multi_decode = true)
7461
  {
7462
    $str = (string)$str;
7463
7464
    if (!isset($str[0])) {
7465
      return '';
7466
    }
7467
7468
    $pattern = '/%u([0-9a-f]{3,4})/i';
7469
    if (preg_match($pattern, $str)) {
7470
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
7471
    }
7472
7473
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
7474
7475
    do {
7476
      $str_compare = $str;
7477
7478
      $str = self::fix_simple_utf8(
7479
          urldecode(
7480
              self::html_entity_decode(
7481
                  self::to_utf8($str),
7482
                  $flags
7483
              )
7484
          )
7485
      );
7486
7487
    } while ($multi_decode === true && $str_compare !== $str);
7488
7489
    return (string)$str;
7490
  }
7491
7492
  /**
7493
   * Return a array with "urlencoded"-win1252 -> UTF-8