Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 3875-3905 (lines=31) @@
3872
   *
3873
   * @return string
3874
   */
3875
  public static function rawurldecode($str, $multi_decode = true)
3876
  {
3877
    $str = (string)$str;
3878
3879
    if (!isset($str[0])) {
3880
      return '';
3881
    }
3882
3883
    $pattern = '/%u([0-9a-f]{3,4})/i';
3884
    if (preg_match($pattern, $str)) {
3885
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
3886
    }
3887
3888
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
3889
3890
    do {
3891
      $str_compare = $str;
3892
3893
      $str = self::fix_simple_utf8(
3894
          rawurldecode(
3895
              self::html_entity_decode(
3896
                  self::to_utf8($str),
3897
                  $flags
3898
              )
3899
          )
3900
      );
3901
3902
    } while ($multi_decode === true && $str_compare !== $str);
3903
3904
    return (string)$str;
3905
  }
3906
3907
  /**
3908
   * alias for "UTF8::remove_bom()"
@@ 7355-7385 (lines=31) @@
7352
   *
7353
   * @return string
7354
   */
7355
  public static function urldecode($str, $multi_decode = true)
7356
  {
7357
    $str = (string)$str;
7358
7359
    if (!isset($str[0])) {
7360
      return '';
7361
    }
7362
7363
    $pattern = '/%u([0-9a-f]{3,4})/i';
7364
    if (preg_match($pattern, $str)) {
7365
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
7366
    }
7367
7368
    $flags = Bootup::is_php('5.4') === true ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
7369
7370
    do {
7371
      $str_compare = $str;
7372
7373
      $str = self::fix_simple_utf8(
7374
          urldecode(
7375
              self::html_entity_decode(
7376
                  self::to_utf8($str),
7377
                  $flags
7378
              )
7379
          )
7380
      );
7381
7382
    } while ($multi_decode === true && $str_compare !== $str);
7383
7384
    return (string)$str;
7385
  }
7386
7387
  /**
7388
   * Return a array with "urlencoded"-win1252 -> UTF-8