Code Duplication    Length = 7-9 lines in 9 locations

src/voku/helper/UTF8.php 9 locations

@@ 360-368 (lines=9) @@
357
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
358
    }
359
360
    if (
361
        $encoding !== 'UTF-8'
362
        &&
363
        $encoding !== 'WINDOWS-1252'
364
        &&
365
        self::$SUPPORT['mbstring'] === false
366
    ) {
367
      trigger_error('UTF8::chr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
368
    }
369
370
    $cacheKey = $code_point . $encoding;
371
    if (isset($CHAR_CACHE[$cacheKey]) === true) {
@@ 760-768 (lines=9) @@
757
        return self::to_iso8859($str);
758
      }
759
760
      if (
761
          $encoding !== 'UTF-8'
762
          &&
763
          $encoding !== 'WINDOWS-1252'
764
          &&
765
          self::$SUPPORT['mbstring'] === false
766
      ) {
767
        trigger_error('UTF8::encode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
768
      }
769
770
      $strEncoded = \mb_convert_encoding(
771
          $str,
@@ 1598-1606 (lines=9) @@
1595
      }
1596
    }
1597
1598
    if (
1599
        $encoding !== 'UTF-8'
1600
        &&
1601
        $encoding !== 'WINDOWS-1252'
1602
        &&
1603
        self::$SUPPORT['mbstring'] === false
1604
    ) {
1605
      trigger_error('UTF8::html_entity_decode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
1606
    }
1607
1608
    do {
1609
      $str_compare = $str;
@@ 4516-4522 (lines=7) @@
4513
      self::checkForSupport();
4514
    }
4515
4516
    if (
4517
        $encoding !== 'UTF-8'
4518
        &&
4519
        self::$SUPPORT['mbstring'] === false
4520
    ) {
4521
      trigger_error('UTF8::stristr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
4522
    }
4523
4524
    if (self::$SUPPORT['mbstring'] === true) {
4525
      return \mb_stristr($haystack, $needle, $before_needle, $encoding);
@@ 5049-5055 (lines=7) @@
5046
      self::checkForSupport();
5047
    }
5048
5049
    if (
5050
        $encoding !== 'UTF-8'
5051
        &&
5052
        self::$SUPPORT['mbstring'] === false
5053
    ) {
5054
      trigger_error('UTF8::strripos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5055
    }
5056
5057
    if (self::$SUPPORT['mbstring'] === true) {
5058
      return \mb_strripos($haystack, $needle, $offset, $encoding);
@@ 5120-5126 (lines=7) @@
5117
      self::checkForSupport();
5118
    }
5119
5120
    if (
5121
        $encoding !== 'UTF-8'
5122
        &&
5123
        self::$SUPPORT['mbstring'] === false
5124
    ) {
5125
      trigger_error('UTF8::strrpos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5126
    }
5127
5128
    if (self::$SUPPORT['mbstring'] === true) {
5129
      return \mb_strrpos($haystack, $needle, $offset, $encoding);
@@ 5228-5234 (lines=7) @@
5225
      self::checkForSupport();
5226
    }
5227
5228
    if (
5229
        $encoding !== 'UTF-8'
5230
        &&
5231
        self::$SUPPORT['mbstring'] === false
5232
    ) {
5233
      trigger_error('UTF8::strstr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5234
    }
5235
5236
    if (self::$SUPPORT['mbstring'] === true) {
5237
      return \mb_strstr($haystack, $needle, $before_needle, $encoding);
@@ 5599-5605 (lines=7) @@
5596
      return \substr($str, $offset, $length ?? $str_length);
5597
    }
5598
5599
    if (
5600
        $encoding !== 'UTF-8'
5601
        &&
5602
        self::$SUPPORT['mbstring'] === false
5603
    ) {
5604
      trigger_error('UTF8::substr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5605
    }
5606
5607
    if (self::$SUPPORT['mbstring'] === true) {
5608
      return \mb_substr($str, $offset, $length, $encoding);
@@ 5756-5762 (lines=7) @@
5753
      self::checkForSupport();
5754
    }
5755
5756
    if (
5757
        $encoding !== 'UTF-8'
5758
        &&
5759
        self::$SUPPORT['mbstring'] === false
5760
    ) {
5761
      trigger_error('UTF8::substr_count() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5762
    }
5763
5764
    if (self::$SUPPORT['mbstring'] === true) {
5765
      return \mb_substr_count($haystack, $needle, $encoding);