Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6018-6033 (lines=16) @@
6015
   *
6016
   * @return string|false The portion of haystack or false if needle is not found.
6017
   */
6018
  public static function strrchr(string $haystack, string $needle, bool $before_needle = false, string $encoding = 'UTF-8', bool $cleanUtf8 = false)
6019
  {
6020
    if ($encoding !== 'UTF-8' && $encoding !== 'CP850') {
6021
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
6022
    }
6023
6024
    if ($cleanUtf8 === true) {
6025
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
6026
      // if invalid characters are found in $haystack before $needle
6027
      $needle = self::clean($needle);
6028
      $haystack = self::clean($haystack);
6029
    }
6030
6031
    // fallback to "mb_"-function via polyfill
6032
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
6033
  }
6034
6035
  /**
6036
   * Reverses characters order in the string.
@@ 6077-6091 (lines=15) @@
6074
   *
6075
   * @return string|false <p>The portion of haystack or<br>false if needle is not found.</p>
6076
   */
6077
  public static function strrichr(string $haystack, string $needle, bool $before_needle = false, string $encoding = 'UTF-8', bool $cleanUtf8 = false)
6078
  {
6079
    if ($encoding !== 'UTF-8' && $encoding !== 'CP850') {
6080
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
6081
    }
6082
6083
    if ($cleanUtf8 === true) {
6084
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
6085
      // if invalid characters are found in $haystack before $needle
6086
      $needle = self::clean($needle);
6087
      $haystack = self::clean($haystack);
6088
    }
6089
6090
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
6091
  }
6092
6093
  /**
6094
   * Find position of last occurrence of a case-insensitive string.