Code Duplication    Length = 29-29 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3199-3227 (lines=29) @@
3196
   *
3197
   * @return string
3198
   */
3199
  public static function rawurldecode(string $str, bool $multi_decode = true): string
3200
  {
3201
    if (!isset($str[0])) {
3202
      return '';
3203
    }
3204
3205
    $pattern = '/%u([0-9a-f]{3,4})/i';
3206
    if (\preg_match($pattern, $str)) {
3207
      $str = (string)\preg_replace($pattern, '&#x\\1;', \rawurldecode($str));
3208
    }
3209
3210
    $flags = ENT_QUOTES | ENT_HTML5;
3211
3212
    do {
3213
      $str_compare = $str;
3214
3215
      $str = self::fix_simple_utf8(
3216
          \rawurldecode(
3217
              self::html_entity_decode(
3218
                  self::to_utf8($str),
3219
                  $flags
3220
              )
3221
          )
3222
      );
3223
3224
    } while ($multi_decode === true && $str_compare !== $str);
3225
3226
    return $str;
3227
  }
3228
3229
  /**
3230
   * alias for "UTF8::remove_bom()"
@@ 6597-6625 (lines=29) @@
6594
   *
6595
   * @return string
6596
   */
6597
  public static function urldecode(string $str, bool $multi_decode = true): string
6598
  {
6599
    if (!isset($str[0])) {
6600
      return '';
6601
    }
6602
6603
    $pattern = '/%u([0-9a-f]{3,4})/i';
6604
    if (\preg_match($pattern, $str)) {
6605
      $str = (string)\preg_replace($pattern, '&#x\\1;', \urldecode($str));
6606
    }
6607
6608
    $flags = ENT_QUOTES | ENT_HTML5;
6609
6610
    do {
6611
      $str_compare = $str;
6612
6613
      $str = self::fix_simple_utf8(
6614
          \urldecode(
6615
              self::html_entity_decode(
6616
                  self::to_utf8($str),
6617
                  $flags
6618
              )
6619
          )
6620
      );
6621
6622
    } while ($multi_decode === true && $str_compare !== $str);
6623
6624
    return $str;
6625
  }
6626
6627
  /**
6628
   * Return a array with "urlencoded"-win1252 -> UTF-8