Code Duplication    Length = 29-29 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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