Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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