Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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