Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5502-5517 (lines=16) @@
5499
   *
5500
   * @return string|false The portion of haystack or false if needle is not found.
5501
   */
5502
  public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5503
  {
5504
    if ($encoding !== 'UTF-8') {
5505
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5506
    }
5507
5508
    if ($cleanUtf8 === true) {
5509
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5510
      // if invalid characters are found in $haystack before $needle
5511
      $needle = self::clean($needle);
5512
      $haystack = self::clean($haystack);
5513
    }
5514
5515
    // fallback to "mb_"-function via polyfill
5516
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
5517
  }
5518
5519
  /**
5520
   * Reverses characters order in the string.
@@ 5560-5574 (lines=15) @@
5557
   *
5558
   * @return string|false <p>The portion of haystack or<br />false if needle is not found.</p>
5559
   */
5560
  public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5561
  {
5562
    if ($encoding !== 'UTF-8') {
5563
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5564
    }
5565
5566
    if ($cleanUtf8 === true) {
5567
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5568
      // if invalid characters are found in $haystack before $needle
5569
      $needle = self::clean($needle);
5570
      $haystack = self::clean($haystack);
5571
    }
5572
5573
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5574
  }
5575
5576
  /**
5577
   * Find position of last occurrence of a case-insensitive string.