Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5752-5767 (lines=16) @@
5749
   *
5750
   * @return string|false The portion of haystack or false if needle is not found.
5751
   */
5752
  public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5753
  {
5754
    if ($encoding !== 'UTF-8') {
5755
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5756
    }
5757
5758
    if ($cleanUtf8 === true) {
5759
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5760
      // if invalid characters are found in $haystack before $needle
5761
      $needle = self::clean($needle);
5762
      $haystack = self::clean($haystack);
5763
    }
5764
5765
    // fallback to "mb_"-function via polyfill
5766
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
5767
  }
5768
5769
  /**
5770
   * Reverses characters order in the string.
@@ 5810-5824 (lines=15) @@
5807
   *
5808
   * @return string|false <p>The portion of haystack or<br>false if needle is not found.</p>
5809
   */
5810
  public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5811
  {
5812
    if ($encoding !== 'UTF-8') {
5813
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5814
    }
5815
5816
    if ($cleanUtf8 === true) {
5817
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5818
      // if invalid characters are found in $haystack before $needle
5819
      $needle = self::clean($needle);
5820
      $haystack = self::clean($haystack);
5821
    }
5822
5823
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5824
  }
5825
5826
  /**
5827
   * Find position of last occurrence of a case-insensitive string.