Code Duplication    Length = 15-16 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5393-5408 (lines=16) @@
5390
   *
5391
   * @return string|false The portion of haystack or false if needle is not found.
5392
   */
5393
  public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false)
5394
  {
5395
    if ($encoding !== 'UTF-8') {
5396
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
5397
    }
5398
5399
    if ($cleanUtf8 === true) {
5400
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5401
      // if invalid characters are found in $haystack before $needle
5402
      $needle = self::clean($needle);
5403
      $haystack = self::clean($haystack);
5404
    }
5405
5406
    // fallback to "mb_"-function via polyfill
5407
    return \mb_strrchr($haystack, $needle, $before_needle, $encoding);
5408
  }
5409
5410
  /**
5411
   * Reverses characters order in the string.
@@ 5451-5465 (lines=15) @@
5448
   *
5449
   * @return string|false <p>The portion of haystack or<br />false if needle is not found.</p>
5450
   */
5451
  public static function strrichr($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
    return \mb_strrichr($haystack, $needle, $before_needle, $encoding);
5465
  }
5466
5467
  /**
5468
   * Find position of last occurrence of a case-insensitive string.