Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5700-5715 (lines=16) @@
5697
   *
5698
   * @return string|false The portion of haystack or false if needle is not found.
5699
   */
5700
  public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5701
  {
5702
    if ($encoding !== 'UTF-8') {
5703
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5704
    }
5705
5706
    if ($cleanUtf8 === true) {
5707
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5708
      // if invalid characters are found in $haystack before $needle
5709
      $needle = self::clean($needle);
5710
      $haystack = self::clean($haystack);
5711
    }
5712
5713
    // fallback to "mb_"-function via polyfill
5714
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
5715
  }
5716
5717
  /**
5718
   * Reverses characters order in the string.
@@ 5758-5772 (lines=15) @@
5755
   *
5756
   * @return string|false <p>The portion of haystack or<br>false if needle is not found.</p>
5757
   */
5758
  public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5759
  {
5760
    if ($encoding !== 'UTF-8') {
5761
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5762
    }
5763
5764
    if ($cleanUtf8 === true) {
5765
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5766
      // if invalid characters are found in $haystack before $needle
5767
      $needle = self::clean($needle);
5768
      $haystack = self::clean($haystack);
5769
    }
5770
5771
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5772
  }
5773
5774
  /**
5775
   * Find position of last occurrence of a case-insensitive string.