Code Duplication    Length = 31-31 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6395-6425 (lines=31) @@
6392
   *
6393
   * @return string
6394
   */
6395
  public static function urldecode($str, $multi_decode = true)
6396
  {
6397
    $str = (string)$str;
6398
6399
    if (!isset($str[0])) {
6400
      return '';
6401
    }
6402
6403
    $pattern = '/%u([0-9a-f]{3,4})/i';
6404
    if (preg_match($pattern, $str)) {
6405
      $str = preg_replace($pattern, '&#x\\1;', urldecode($str));
6406
    }
6407
6408
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6409
6410
    do {
6411
      $str_compare = $str;
6412
6413
      $str = self::fix_simple_utf8(
6414
          urldecode(
6415
              self::html_entity_decode(
6416
                  self::to_utf8($str),
6417
                  $flags
6418
              )
6419
          )
6420
      );
6421
6422
    } while ($multi_decode === true && $str_compare !== $str);
6423
6424
    return (string)$str;
6425
  }
6426
6427
  /**
6428
   * Multi decode html entity & fix urlencoded-win1252-chars.
@@ 6446-6476 (lines=31) @@
6443
   *
6444
   * @return string
6445
   */
6446
  public static function rawurldecode($str, $multi_decode = true)
6447
  {
6448
    $str = (string)$str;
6449
6450
    if (!isset($str[0])) {
6451
      return '';
6452
    }
6453
6454
    $pattern = '/%u([0-9a-f]{3,4})/i';
6455
    if (preg_match($pattern, $str)) {
6456
      $str = preg_replace($pattern, '&#x\\1;', rawurldecode($str));
6457
    }
6458
6459
    $flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
6460
6461
    do {
6462
      $str_compare = $str;
6463
6464
      $str = self::fix_simple_utf8(
6465
          rawurldecode(
6466
              self::html_entity_decode(
6467
                  self::to_utf8($str),
6468
                  $flags
6469
              )
6470
          )
6471
      );
6472
6473
    } while ($multi_decode === true && $str_compare !== $str);
6474
6475
    return (string)$str;
6476
  }
6477
6478
  /**
6479
   * Return a array with "urlencoded"-win1252 -> UTF-8