Code Duplication    Length = 44-45 lines in 2 locations

includes/libraries/protect/AntiXSS/UTF8.php 2 locations

@@ 6061-6105 (lines=45) @@
6058
   *
6059
   * @return string str with all alphabetic characters converted to lowercase.
6060
   */
6061
  public static function strtolower($str, $encoding = 'UTF-8', $cleanUtf8 = false, $lang = null)
6062
  {
6063
    // init
6064
    $str = (string)$str;
6065
6066
    if (!isset($str[0])) {
6067
      return '';
6068
    }
6069
6070
    if ($cleanUtf8 === true) {
6071
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
6072
      // if invalid characters are found in $haystack before $needle
6073
      $str = self::clean($str);
6074
    }
6075
6076
    if ($encoding !== 'UTF-8') {
6077
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
6078
    }
6079
6080
    if ($lang !== null) {
6081
      if (!isset(self::$SUPPORT['already_checked_via_portable_utf8'])) {
6082
        self::checkForSupport();
6083
      }
6084
6085
      if (
6086
          self::$SUPPORT['intl'] === true
6087
          &&
6088
          Bootup::is_php('5.4') === true
6089
      ) {
6090
6091
        $langCode = $lang . '-Lower';
6092
        if (!in_array($langCode, self::$SUPPORT['intl__transliterator_list_ids'], true)) {
6093
          trigger_error('UTF8::strtolower() without intl for special language: ' . $lang, E_USER_WARNING);
6094
6095
          $langCode = 'Any-Lower';
6096
        }
6097
6098
        return transliterator_transliterate($langCode, $str);
6099
      }
6100
6101
      trigger_error('UTF8::strtolower() without intl + PHP >= 5.4 cannot handle the "lang"-parameter: ' . $lang, E_USER_WARNING);
6102
    }
6103
6104
    return \mb_strtolower($str, $encoding);
6105
  }
6106
6107
  /**
6108
   * Generic case sensitive transformation for collation matching.
@@ 6132-6175 (lines=44) @@
6129
   *
6130
   * @return string str with all alphabetic characters converted to uppercase.
6131
   */
6132
  public static function strtoupper($str, $encoding = 'UTF-8', $cleanUtf8 = false, $lang = null)
6133
  {
6134
    $str = (string)$str;
6135
6136
    if (!isset($str[0])) {
6137
      return '';
6138
    }
6139
6140
    if ($cleanUtf8 === true) {
6141
      // "\mb_strpos" and "\iconv_strpos" returns wrong position,
6142
      // if invalid characters are found in $haystack before $needle
6143
      $str = self::clean($str);
6144
    }
6145
6146
    if ($encoding !== 'UTF-8') {
6147
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
6148
    }
6149
6150
    if ($lang !== null) {
6151
      if (!isset(self::$SUPPORT['already_checked_via_portable_utf8'])) {
6152
        self::checkForSupport();
6153
      }
6154
6155
      if (
6156
          self::$SUPPORT['intl'] === true
6157
          &&
6158
          Bootup::is_php('5.4') === true
6159
      ) {
6160
6161
        $langCode = $lang . '-Upper';
6162
        if (!in_array($langCode, self::$SUPPORT['intl__transliterator_list_ids'], true)) {
6163
          trigger_error('UTF8::strtoupper() without intl for special language: ' . $lang, E_USER_WARNING);
6164
6165
          $langCode = 'Any-Upper';
6166
        }
6167
6168
        return transliterator_transliterate($langCode, $str);
6169
      }
6170
6171
      trigger_error('UTF8::strtolower() without intl + PHP >= 5.4 cannot handle the "lang"-parameter: ' . $lang, E_USER_WARNING);
6172
    }
6173
6174
    return \mb_strtoupper($str, $encoding);
6175
  }
6176
6177
  /**
6178
   * Translate characters or replace sub-strings.