Code Duplication    Length = 29-29 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3278-3306 (lines=29) @@
3275
   *
3276
   * @return string
3277
   */
3278
  public static function rawurldecode(string $str, bool $multi_decode = true): string
3279
  {
3280
    if (!isset($str[0])) {
3281
      return '';
3282
    }
3283
3284
    $pattern = '/%u([0-9a-f]{3,4})/i';
3285
    if (\preg_match($pattern, $str)) {
3286
      $str = (string)\preg_replace($pattern, '&#x\\1;', \rawurldecode($str));
3287
    }
3288
3289
    $flags = ENT_QUOTES | ENT_HTML5;
3290
3291
    do {
3292
      $str_compare = $str;
3293
3294
      $str = self::fix_simple_utf8(
3295
          \rawurldecode(
3296
              self::html_entity_decode(
3297
                  self::to_utf8($str),
3298
                  $flags
3299
              )
3300
          )
3301
      );
3302
3303
    } while ($multi_decode === true && $str_compare !== $str);
3304
3305
    return $str;
3306
  }
3307
3308
  /**
3309
   * alias for "UTF8::remove_bom()"
@@ 6675-6703 (lines=29) @@
6672
   *
6673
   * @return string
6674
   */
6675
  public static function urldecode(string $str, bool $multi_decode = true): string
6676
  {
6677
    if (!isset($str[0])) {
6678
      return '';
6679
    }
6680
6681
    $pattern = '/%u([0-9a-f]{3,4})/i';
6682
    if (\preg_match($pattern, $str)) {
6683
      $str = (string)\preg_replace($pattern, '&#x\\1;', \urldecode($str));
6684
    }
6685
6686
    $flags = ENT_QUOTES | ENT_HTML5;
6687
6688
    do {
6689
      $str_compare = $str;
6690
6691
      $str = self::fix_simple_utf8(
6692
          \urldecode(
6693
              self::html_entity_decode(
6694
                  self::to_utf8($str),
6695
                  $flags
6696
              )
6697
          )
6698
      );
6699
6700
    } while ($multi_decode === true && $str_compare !== $str);
6701
6702
    return $str;
6703
  }
6704
6705
  /**
6706
   * Return a array with "urlencoded"-win1252 -> UTF-8