Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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