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) {
@@ 1393-1401 (lines=9) @@
1390
        return self::to_iso8859($str);
1391
      }
1392
1393
      if (
1394
          $encoding !== 'UTF-8'
1395
          &&
1396
          $encoding !== 'WINDOWS-1252'
1397
          &&
1398
          self::$SUPPORT['mbstring'] === false
1399
      ) {
1400
        trigger_error('UTF8::encode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
1401
      }
1402
1403
      $strEncoded = \mb_convert_encoding(
1404
          $str,
@@ 2292-2300 (lines=9) @@
2289
      }
2290
    }
2291
2292
    if (
2293
        $encoding !== 'UTF-8'
2294
        &&
2295
        $encoding !== 'WINDOWS-1252'
2296
        &&
2297
        self::$SUPPORT['mbstring'] === false
2298
    ) {
2299
      trigger_error('UTF8::html_entity_decode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
2300
    }
2301
2302
    do {
2303
      $str_compare = $str;
@@ 5340-5346 (lines=7) @@
5337
      self::checkForSupport();
5338
    }
5339
5340
    if (
5341
        $encoding !== 'UTF-8'
5342
        &&
5343
        self::$SUPPORT['mbstring'] === false
5344
    ) {
5345
      trigger_error('UTF8::stristr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5346
    }
5347
5348
    if (self::$SUPPORT['mbstring'] === true) {
5349
      return \mb_stristr($haystack, $needle, $before_needle, $encoding);
@@ 5885-5891 (lines=7) @@
5882
      self::checkForSupport();
5883
    }
5884
5885
    if (
5886
        $encoding !== 'UTF-8'
5887
        &&
5888
        self::$SUPPORT['mbstring'] === false
5889
    ) {
5890
      trigger_error('UTF8::strripos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5891
    }
5892
5893
    if (self::$SUPPORT['mbstring'] === true) {
5894
      return \mb_strripos($haystack, $needle, $offset, $encoding);
@@ 5968-5974 (lines=7) @@
5965
      self::checkForSupport();
5966
    }
5967
5968
    if (
5969
        $encoding !== 'UTF-8'
5970
        &&
5971
        self::$SUPPORT['mbstring'] === false
5972
    ) {
5973
      trigger_error('UTF8::strrpos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5974
    }
5975
5976
    if (self::$SUPPORT['mbstring'] === true) {
5977
      return \mb_strrpos($haystack, $needle, $offset, $encoding);
@@ 6082-6088 (lines=7) @@
6079
      self::checkForSupport();
6080
    }
6081
6082
    if (
6083
        $encoding !== 'UTF-8'
6084
        &&
6085
        self::$SUPPORT['mbstring'] === false
6086
    ) {
6087
      trigger_error('UTF8::strstr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
6088
    }
6089
6090
    if (self::$SUPPORT['mbstring'] === true) {
6091
      return \mb_strstr($haystack, $needle, $before_needle, $encoding);
@@ 6486-6492 (lines=7) @@
6483
      return substr($str, $offset, $length === null ? $str_length : $length);
6484
    }
6485
6486
    if (
6487
        $encoding !== 'UTF-8'
6488
        &&
6489
        self::$SUPPORT['mbstring'] === false
6490
    ) {
6491
      trigger_error('UTF8::substr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
6492
    }
6493
6494
    if (self::$SUPPORT['mbstring'] === true) {
6495
      return \mb_substr($str, $offset, $length, $encoding);
@@ 6649-6655 (lines=7) @@
6646
      self::checkForSupport();
6647
    }
6648
6649
    if (
6650
        $encoding !== 'UTF-8'
6651
        &&
6652
        self::$SUPPORT['mbstring'] === false
6653
    ) {
6654
      trigger_error('UTF8::substr_count() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
6655
    }
6656
6657
    if (self::$SUPPORT['mbstring'] === true) {
6658
      return \mb_substr_count($haystack, $needle, $encoding);