Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5032-5047 (lines=16) @@
5029
   *
5030
   * @return string|false The portion of haystack or false if needle is not found.
5031
   */
5032
  public static function strrchr(string $haystack, string $needle, bool $before_needle = false, string $encoding = 'UTF-8', bool $cleanUtf8 = false)
5033
  {
5034
    if ($encoding !== 'UTF-8' && $encoding !== 'CP850') {
5035
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5036
    }
5037
5038
    if ($cleanUtf8 === true) {
5039
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5040
      // if invalid characters are found in $haystack before $needle
5041
      $needle = self::clean($needle);
5042
      $haystack = self::clean($haystack);
5043
    }
5044
5045
    // fallback to "mb_"-function via polyfill
5046
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
5047
  }
5048
5049
  /**
5050
   * Reverses characters order in the string.
@@ 5088-5102 (lines=15) @@
5085
   *
5086
   * @return string|false <p>The portion of haystack or<br>false if needle is not found.</p>
5087
   */
5088
  public static function strrichr(string $haystack, string $needle, bool $before_needle = false, string $encoding = 'UTF-8', bool $cleanUtf8 = false)
5089
  {
5090
    if ($encoding !== 'UTF-8' && $encoding !== 'CP850') {
5091
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5092
    }
5093
5094
    if ($cleanUtf8 === true) {
5095
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5096
      // if invalid characters are found in $haystack before $needle
5097
      $needle = self::clean($needle);
5098
      $haystack = self::clean($haystack);
5099
    }
5100
5101
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5102
  }
5103
5104
  /**
5105
   * Find position of last occurrence of a case-insensitive string.