Code Duplication    Length = 29-29 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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