Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5551-5566 (lines=16) @@
5548
   *
5549
   * @return string|false The portion of haystack or false if needle is not found.
5550
   */
5551
  public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5552
  {
5553
    if ($encoding !== 'UTF-8') {
5554
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5555
    }
5556
5557
    if ($cleanUtf8 === true) {
5558
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5559
      // if invalid characters are found in $haystack before $needle
5560
      $needle = self::clean($needle);
5561
      $haystack = self::clean($haystack);
5562
    }
5563
5564
    // fallback to "mb_"-function via polyfill
5565
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
5566
  }
5567
5568
  /**
5569
   * Reverses characters order in the string.
@@ 5609-5623 (lines=15) @@
5606
   *
5607
   * @return string|false <p>The portion of haystack or<br />false if needle is not found.</p>
5608
   */
5609
  public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5610
  {
5611
    if ($encoding !== 'UTF-8') {
5612
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5613
    }
5614
5615
    if ($cleanUtf8 === true) {
5616
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5617
      // if invalid characters are found in $haystack before $needle
5618
      $needle = self::clean($needle);
5619
      $haystack = self::clean($haystack);
5620
    }
5621
5622
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5623
  }
5624
5625
  /**
5626
   * Find position of last occurrence of a case-insensitive string.