Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3571-3601 (lines=31) @@
3568
   *
3569
   * @return string
3570
   */
3571
  public static function rawurldecode($str, $multi_decode = true)
3572
  {
3573
    $str = (string)$str;
3574
3575
    if (!isset($str[0])) {
3576
      return '';
3577
    }
3578
3579
    $pattern = '/%u([0-9a-f]{3,4})/i';
3580
    if (preg_match($pattern, $str)) {
3581
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3582
    }
3583
3584
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3585
3586
    do {
3587
      $str_compare = $str;
3588
3589
      $str = self::fix_simple_utf8(
3590
          rawurldecode(
3591
              self::html_entity_decode(
3592
                  self::to_utf8($str),
3593
                  $flags
3594
              )
3595
          )
3596
      );
3597
3598
    } while ($multi_decode === true && $str_compare !== $str);
3599
3600
    return (string)$str;
3601
  }
3602
3603
  /**
3604
   * alias for "UTF8::remove_bom()"
@@ 6585-6615 (lines=31) @@
6582
   *
6583
   * @return string
6584
   */
6585
  public static function urldecode($str, $multi_decode = true)
6586
  {
6587
    $str = (string)$str;
6588
6589
    if (!isset($str[0])) {
6590
      return '';
6591
    }
6592
6593
    $pattern = '/%u([0-9a-f]{3,4})/i';
6594
    if (preg_match($pattern, $str)) {
6595
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
6596
    }
6597
6598
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6599
6600
    do {
6601
      $str_compare = $str;
6602
6603
      $str = self::fix_simple_utf8(
6604
          urldecode(
6605
              self::html_entity_decode(
6606
                  self::to_utf8($str),
6607
                  $flags
6608
              )
6609
          )
6610
      );
6611
6612
    } while ($multi_decode === true && $str_compare !== $str);
6613
6614
    return (string)$str;
6615
  }
6616
6617
  /**
6618
   * Return a array with "urlencoded"-win1252 -> UTF-8