Code Duplication    Length = 20-21 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5530-5550 (lines=21) @@
5527
   *
5528
   * @return string str with all alphabetic characters converted to lowercase.
5529
   */
5530
  public static function strtolower($str, $encoding = 'UTF-8', $cleanUtf8 = false)
5531
  {
5532
    // init
5533
    $str = (string)$str;
5534
5535
    if (!isset($str[0])) {
5536
      return '';
5537
    }
5538
5539
    if ($cleanUtf8 === true) {
5540
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5541
      // if invalid characters are found in $haystack before $needle
5542
      $str = self::clean($str);
5543
    }
5544
5545
    if ($encoding !== 'UTF-8') {
5546
      $encoding = self::normalize_encoding($encoding);
5547
    }
5548
5549
    return \mb_strtolower($str, $encoding);
5550
  }
5551
5552
  /**
5553
   * Generic case sensitive transformation for collation matching.
@@ 5576-5595 (lines=20) @@
5573
   *
5574
   * @return string str with all alphabetic characters converted to uppercase.
5575
   */
5576
  public static function strtoupper($str, $encoding = 'UTF-8', $cleanUtf8 = false)
5577
  {
5578
    $str = (string)$str;
5579
5580
    if (!isset($str[0])) {
5581
      return '';
5582
    }
5583
5584
    if ($cleanUtf8 === true) {
5585
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5586
      // if invalid characters are found in $haystack before $needle
5587
      $str = self::clean($str);
5588
    }
5589
5590
    if ($encoding !== 'UTF-8') {
5591
      $encoding = self::normalize_encoding($encoding);
5592
    }
5593
5594
    return \mb_strtoupper($str, $encoding);
5595
  }
5596
5597
  /**
5598
   * Translate characters or replace sub-strings.