Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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