Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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