Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5451-5466 (lines=16) @@
5448
   *
5449
   * @return string|false The portion of haystack or false if needle is not found.
5450
   */
5451
  public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5452
  {
5453
    if ($encoding !== 'UTF-8') {
5454
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5455
    }
5456
5457
    if ($cleanUtf8 === true) {
5458
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5459
      // if invalid characters are found in $haystack before $needle
5460
      $needle = self::clean($needle);
5461
      $haystack = self::clean($haystack);
5462
    }
5463
5464
    // fallback to "mb_"-function via polyfill
5465
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
5466
  }
5467
5468
  /**
5469
   * Reverses characters order in the string.
@@ 5509-5523 (lines=15) @@
5506
   *
5507
   * @return string|false <p>The portion of haystack or<br />false if needle is not found.</p>
5508
   */
5509
  public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5510
  {
5511
    if ($encoding !== 'UTF-8') {
5512
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5513
    }
5514
5515
    if ($cleanUtf8 === true) {
5516
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5517
      // if invalid characters are found in $haystack before $needle
5518
      $needle = self::clean($needle);
5519
      $haystack = self::clean($haystack);
5520
    }
5521
5522
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5523
  }
5524
5525
  /**
5526
   * Find position of last occurrence of a case-insensitive string.