Code Duplication    Length = 20-21 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5714-5734 (lines=21) @@
5711
   *
5712
   * @return string str with all alphabetic characters converted to lowercase.
5713
   */
5714
  public static function strtolower($str, $encoding = 'UTF-8', $cleanUtf8 = false)
5715
  {
5716
    // init
5717
    $str = (string)$str;
5718
5719
    if (!isset($str[0])) {
5720
      return '';
5721
    }
5722
5723
    if ($cleanUtf8 === true) {
5724
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5725
      // if invalid characters are found in $haystack before $needle
5726
      $str = self::clean($str);
5727
    }
5728
5729
    if ($encoding !== 'UTF-8') {
5730
      $encoding = self::normalize_encoding($encoding);
5731
    }
5732
5733
    return \mb_strtolower($str, $encoding);
5734
  }
5735
5736
  /**
5737
   * Generic case sensitive transformation for collation matching.
@@ 5760-5779 (lines=20) @@
5757
   *
5758
   * @return string str with all alphabetic characters converted to uppercase.
5759
   */
5760
  public static function strtoupper($str, $encoding = 'UTF-8', $cleanUtf8 = false)
5761
  {
5762
    $str = (string)$str;
5763
5764
    if (!isset($str[0])) {
5765
      return '';
5766
    }
5767
5768
    if ($cleanUtf8 === true) {
5769
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
5770
      // if invalid characters are found in $haystack before $needle
5771
      $str = self::clean($str);
5772
    }
5773
5774
    if ($encoding !== 'UTF-8') {
5775
      $encoding = self::normalize_encoding($encoding);
5776
    }
5777
5778
    return \mb_strtoupper($str, $encoding);
5779
  }
5780
5781
  /**
5782
   * Translate characters or replace sub-strings.