Code Duplication    Length = 20-21 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5578-5598 (lines=21) @@
5575
   *
5576
   * @return string str with all alphabetic characters converted to lowercase.
5577
   */
5578
  public static function strtolower($str, $encoding = 'UTF-8', $cleanUtf8 = false)
5579
  {
5580
    // init
5581
    $str = (string)$str;
5582
5583
    if (!isset($str[0])) {
5584
      return '';
5585
    }
5586
5587
    if ($cleanUtf8 === true) {
5588
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5589
      // if invalid characters are found in $haystack before $needle
5590
      $str = self::clean($str);
5591
    }
5592
5593
    if ($encoding !== 'UTF-8') {
5594
      $encoding = self::normalize_encoding($encoding);
5595
    }
5596
5597
    return \mb_strtolower($str, $encoding);
5598
  }
5599
5600
  /**
5601
   * Generic case sensitive transformation for collation matching.
@@ 5624-5643 (lines=20) @@
5621
   *
5622
   * @return string str with all alphabetic characters converted to uppercase.
5623
   */
5624
  public static function strtoupper($str, $encoding = 'UTF-8', $cleanUtf8 = false)
5625
  {
5626
    $str = (string)$str;
5627
5628
    if (!isset($str[0])) {
5629
      return '';
5630
    }
5631
5632
    if ($cleanUtf8 === true) {
5633
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5634
      // if invalid characters are found in $haystack before $needle
5635
      $str = self::clean($str);
5636
    }
5637
5638
    if ($encoding !== 'UTF-8') {
5639
      $encoding = self::normalize_encoding($encoding);
5640
    }
5641
5642
    return \mb_strtoupper($str, $encoding);
5643
  }
5644
5645
  /**
5646
   * Translate characters or replace sub-strings.