Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3599-3629 (lines=31) @@
3596
   *
3597
   * @return string
3598
   */
3599
  public static function rawurldecode($str, $multi_decode = true)
3600
  {
3601
    $str = (string)$str;
3602
3603
    if (!isset($str[0])) {
3604
      return '';
3605
    }
3606
3607
    $pattern = '/%u([0-9a-f]{3,4})/i';
3608
    if (preg_match($pattern, $str)) {
3609
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3610
    }
3611
3612
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3613
3614
    do {
3615
      $str_compare = $str;
3616
3617
      $str = self::fix_simple_utf8(
3618
          rawurldecode(
3619
              self::html_entity_decode(
3620
                  self::to_utf8($str),
3621
                  $flags
3622
              )
3623
          )
3624
      );
3625
3626
    } while ($multi_decode === true && $str_compare !== $str);
3627
3628
    return (string)$str;
3629
  }
3630
3631
  /**
3632
   * alias for "UTF8::remove_bom()"
@@ 6642-6672 (lines=31) @@
6639
   *
6640
   * @return string
6641
   */
6642
  public static function urldecode($str, $multi_decode = true)
6643
  {
6644
    $str = (string)$str;
6645
6646
    if (!isset($str[0])) {
6647
      return '';
6648
    }
6649
6650
    $pattern = '/%u([0-9a-f]{3,4})/i';
6651
    if (preg_match($pattern, $str)) {
6652
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
6653
    }
6654
6655
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6656
6657
    do {
6658
      $str_compare = $str;
6659
6660
      $str = self::fix_simple_utf8(
6661
          urldecode(
6662
              self::html_entity_decode(
6663
                  self::to_utf8($str),
6664
                  $flags
6665
              )
6666
          )
6667
      );
6668
6669
    } while ($multi_decode === true && $str_compare !== $str);
6670
6671
    return (string)$str;
6672
  }
6673
6674
  /**
6675
   * Return a array with "urlencoded"-win1252 -> UTF-8