Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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