Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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