Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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