Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5493-5508 (lines=16) @@
5490
   *
5491
   * @return string|false The portion of haystack or false if needle is not found.
5492
   */
5493
  public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5494
  {
5495
    if ($encoding !== 'UTF-8') {
5496
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5497
    }
5498
5499
    if ($cleanUtf8 === true) {
5500
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5501
      // if invalid characters are found in $haystack before $needle
5502
      $needle = self::clean($needle);
5503
      $haystack = self::clean($haystack);
5504
    }
5505
5506
    // fallback to "mb_"-function via polyfill
5507
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
5508
  }
5509
5510
  /**
5511
   * Reverses characters order in the string.
@@ 5551-5565 (lines=15) @@
5548
   *
5549
   * @return string|false <p>The portion of haystack or<br />false if needle is not found.</p>
5550
   */
5551
  public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5552
  {
5553
    if ($encoding !== 'UTF-8') {
5554
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5555
    }
5556
5557
    if ($cleanUtf8 === true) {
5558
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5559
      // if invalid characters are found in $haystack before $needle
5560
      $needle = self::clean($needle);
5561
      $haystack = self::clean($haystack);
5562
    }
5563
5564
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5565
  }
5566
5567
  /**
5568
   * Find position of last occurrence of a case-insensitive string.