Code Duplication    Length = 7-9 lines in 9 locations

src/voku/helper/UTF8.php 9 locations

@@ 976-984 (lines=9) @@
973
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
974
    }
975
976
    if (
977
        $encoding !== 'UTF-8'
978
        &&
979
        $encoding !== 'WINDOWS-1252'
980
        &&
981
        self::$SUPPORT['mbstring'] === false
982
    ) {
983
      trigger_error('UTF8::chr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
984
    }
985
986
    $cacheKey = $code_point . $encoding;
987
    if (isset($CHAR_CACHE[$cacheKey]) === true) {
@@ 1392-1400 (lines=9) @@
1389
        return self::to_iso8859($str);
1390
      }
1391
1392
      if (
1393
          $encoding !== 'UTF-8'
1394
          &&
1395
          $encoding !== 'WINDOWS-1252'
1396
          &&
1397
          self::$SUPPORT['mbstring'] === false
1398
      ) {
1399
        trigger_error('UTF8::encode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
1400
      }
1401
1402
      $strEncoded = \mb_convert_encoding(
1403
          $str,
@@ 2291-2299 (lines=9) @@
2288
      }
2289
    }
2290
2291
    if (
2292
        $encoding !== 'UTF-8'
2293
        &&
2294
        $encoding !== 'WINDOWS-1252'
2295
        &&
2296
        self::$SUPPORT['mbstring'] === false
2297
    ) {
2298
      trigger_error('UTF8::html_entity_decode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
2299
    }
2300
2301
    do {
2302
      $str_compare = $str;
@@ 5332-5338 (lines=7) @@
5329
      self::checkForSupport();
5330
    }
5331
5332
    if (
5333
        $encoding !== 'UTF-8'
5334
        &&
5335
        self::$SUPPORT['mbstring'] === false
5336
    ) {
5337
      trigger_error('UTF8::stristr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5338
    }
5339
5340
    if (self::$SUPPORT['mbstring'] === true) {
5341
      return \mb_stristr($haystack, $needle, $before_needle, $encoding);
@@ 5877-5883 (lines=7) @@
5874
      self::checkForSupport();
5875
    }
5876
5877
    if (
5878
        $encoding !== 'UTF-8'
5879
        &&
5880
        self::$SUPPORT['mbstring'] === false
5881
    ) {
5882
      trigger_error('UTF8::strripos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5883
    }
5884
5885
    if (self::$SUPPORT['mbstring'] === true) {
5886
      return \mb_strripos($haystack, $needle, $offset, $encoding);
@@ 5960-5966 (lines=7) @@
5957
      self::checkForSupport();
5958
    }
5959
5960
    if (
5961
        $encoding !== 'UTF-8'
5962
        &&
5963
        self::$SUPPORT['mbstring'] === false
5964
    ) {
5965
      trigger_error('UTF8::strrpos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5966
    }
5967
5968
    if (self::$SUPPORT['mbstring'] === true) {
5969
      return \mb_strrpos($haystack, $needle, $offset, $encoding);
@@ 6074-6080 (lines=7) @@
6071
      self::checkForSupport();
6072
    }
6073
6074
    if (
6075
        $encoding !== 'UTF-8'
6076
        &&
6077
        self::$SUPPORT['mbstring'] === false
6078
    ) {
6079
      trigger_error('UTF8::strstr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
6080
    }
6081
6082
    if (self::$SUPPORT['mbstring'] === true) {
6083
      return \mb_strstr($haystack, $needle, $before_needle, $encoding);
@@ 6478-6484 (lines=7) @@
6475
      return substr($str, $offset, $length === null ? $str_length : $length);
6476
    }
6477
6478
    if (
6479
        $encoding !== 'UTF-8'
6480
        &&
6481
        self::$SUPPORT['mbstring'] === false
6482
    ) {
6483
      trigger_error('UTF8::substr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
6484
    }
6485
6486
    if (self::$SUPPORT['mbstring'] === true) {
6487
      return \mb_substr($str, $offset, $length, $encoding);
@@ 6641-6647 (lines=7) @@
6638
      self::checkForSupport();
6639
    }
6640
6641
    if (
6642
        $encoding !== 'UTF-8'
6643
        &&
6644
        self::$SUPPORT['mbstring'] === false
6645
    ) {
6646
      trigger_error('UTF8::substr_count() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
6647
    }
6648
6649
    if (self::$SUPPORT['mbstring'] === true) {
6650
      return \mb_substr_count($haystack, $needle, $encoding);