Code Duplication    Length = 29-29 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3900-3928 (lines=29) @@
3897
   *
3898
   * @return string
3899
   */
3900
  public static function rawurldecode(string $str, bool $multi_decode = true): string
3901
  {
3902
    if (!isset($str[0])) {
3903
      return '';
3904
    }
3905
3906
    $pattern = '/%u([0-9a-f]{3,4})/i';
3907
    if (\preg_match($pattern, $str)) {
3908
      $str = (string)\preg_replace($pattern, '&#x\\1;', \rawurldecode($str));
3909
    }
3910
3911
    $flags = ENT_QUOTES | ENT_HTML5;
3912
3913
    do {
3914
      $str_compare = $str;
3915
3916
      $str = self::fix_simple_utf8(
3917
          \rawurldecode(
3918
              self::html_entity_decode(
3919
                  self::to_utf8($str),
3920
                  $flags
3921
              )
3922
          )
3923
      );
3924
3925
    } while ($multi_decode === true && $str_compare !== $str);
3926
3927
    return $str;
3928
  }
3929
3930
  /**
3931
   * @param array $strings
@@ 7724-7752 (lines=29) @@
7721
   *
7722
   * @return string
7723
   */
7724
  public static function urldecode(string $str, bool $multi_decode = true): string
7725
  {
7726
    if (!isset($str[0])) {
7727
      return '';
7728
    }
7729
7730
    $pattern = '/%u([0-9a-f]{3,4})/i';
7731
    if (\preg_match($pattern, $str)) {
7732
      $str = (string)\preg_replace($pattern, '&#x\\1;', \urldecode($str));
7733
    }
7734
7735
    $flags = ENT_QUOTES | ENT_HTML5;
7736
7737
    do {
7738
      $str_compare = $str;
7739
7740
      $str = self::fix_simple_utf8(
7741
          \urldecode(
7742
              self::html_entity_decode(
7743
                  self::to_utf8($str),
7744
                  $flags
7745
              )
7746
          )
7747
      );
7748
7749
    } while ($multi_decode === true && $str_compare !== $str);
7750
7751
    return $str;
7752
  }
7753
7754
  /**
7755
   * Return a array with "urlencoded"-win1252 -> UTF-8