Code Duplication    Length = 29-29 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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