Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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