Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 4939-4954 (lines=16) @@
4936
   *
4937
   * @return string|false The portion of haystack or false if needle is not found.
4938
   */
4939
  public static function strrchr(string $haystack, string $needle, bool $before_needle = false, string $encoding = 'UTF-8', bool $cleanUtf8 = false)
4940
  {
4941
    if ($encoding !== 'UTF-8') {
4942
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
4943
    }
4944
4945
    if ($cleanUtf8 === true) {
4946
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
4947
      // if invalid characters are found in $haystack before $needle
4948
      $needle = self::clean($needle);
4949
      $haystack = self::clean($haystack);
4950
    }
4951
4952
    // fallback to "mb_"-function via polyfill
4953
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
4954
  }
4955
4956
  /**
4957
   * Reverses characters order in the string.
@@ 4995-5009 (lines=15) @@
4992
   *
4993
   * @return string|false <p>The portion of haystack or<br>false if needle is not found.</p>
4994
   */
4995
  public static function strrichr(string $haystack, string $needle, bool $before_needle = false, string $encoding = 'UTF-8', bool $cleanUtf8 = false)
4996
  {
4997
    if ($encoding !== 'UTF-8') {
4998
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
4999
    }
5000
5001
    if ($cleanUtf8 === true) {
5002
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5003
      // if invalid characters are found in $haystack before $needle
5004
      $needle = self::clean($needle);
5005
      $haystack = self::clean($haystack);
5006
    }
5007
5008
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5009
  }
5010
5011
  /**
5012
   * Find position of last occurrence of a case-insensitive string.