Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5668-5683 (lines=16) @@
5665
   *
5666
   * @return string|false The portion of haystack or false if needle is not found.
5667
   */
5668
  public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5669
  {
5670
    if ($encoding !== 'UTF-8') {
5671
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5672
    }
5673
5674
    if ($cleanUtf8 === true) {
5675
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5676
      // if invalid characters are found in $haystack before $needle
5677
      $needle = self::clean($needle);
5678
      $haystack = self::clean($haystack);
5679
    }
5680
5681
    // fallback to "mb_"-function via polyfill
5682
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
5683
  }
5684
5685
  /**
5686
   * Reverses characters order in the string.
@@ 5726-5740 (lines=15) @@
5723
   *
5724
   * @return string|false <p>The portion of haystack or<br />false if needle is not found.</p>
5725
   */
5726
  public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5727
  {
5728
    if ($encoding !== 'UTF-8') {
5729
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5730
    }
5731
5732
    if ($cleanUtf8 === true) {
5733
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5734
      // if invalid characters are found in $haystack before $needle
5735
      $needle = self::clean($needle);
5736
      $haystack = self::clean($haystack);
5737
    }
5738
5739
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5740
  }
5741
5742
  /**
5743
   * Find position of last occurrence of a case-insensitive string.