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,
@@ 1594-1602 (lines=9) @@
1591
      $flags = ENT_QUOTES | ENT_HTML5;
1592
    }
1593
1594
    if (
1595
        $encoding !== 'UTF-8'
1596
        &&
1597
        $encoding !== 'WINDOWS-1252'
1598
        &&
1599
        self::$SUPPORT['mbstring'] === false
1600
    ) {
1601
      \trigger_error('UTF8::html_entity_decode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
1602
    }
1603
1604
    do {
1605
      $str_compare = $str;
@@ 4512-4518 (lines=7) @@
4509
      self::checkForSupport();
4510
    }
4511
4512
    if (
4513
        $encoding !== 'UTF-8'
4514
        &&
4515
        self::$SUPPORT['mbstring'] === false
4516
    ) {
4517
      \trigger_error('UTF8::stristr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
4518
    }
4519
4520
    if (self::$SUPPORT['mbstring'] === true) {
4521
      return \mb_stristr($haystack, $needle, $before_needle, $encoding);
@@ 5045-5051 (lines=7) @@
5042
      self::checkForSupport();
5043
    }
5044
5045
    if (
5046
        $encoding !== 'UTF-8'
5047
        &&
5048
        self::$SUPPORT['mbstring'] === false
5049
    ) {
5050
      \trigger_error('UTF8::strripos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5051
    }
5052
5053
    if (self::$SUPPORT['mbstring'] === true) {
5054
      return \mb_strripos($haystack, $needle, $offset, $encoding);
@@ 5116-5122 (lines=7) @@
5113
      self::checkForSupport();
5114
    }
5115
5116
    if (
5117
        $encoding !== 'UTF-8'
5118
        &&
5119
        self::$SUPPORT['mbstring'] === false
5120
    ) {
5121
      \trigger_error('UTF8::strrpos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5122
    }
5123
5124
    if (self::$SUPPORT['mbstring'] === true) {
5125
      return \mb_strrpos($haystack, $needle, $offset, $encoding);
@@ 5224-5230 (lines=7) @@
5221
      self::checkForSupport();
5222
    }
5223
5224
    if (
5225
        $encoding !== 'UTF-8'
5226
        &&
5227
        self::$SUPPORT['mbstring'] === false
5228
    ) {
5229
      \trigger_error('UTF8::strstr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5230
    }
5231
5232
    if (self::$SUPPORT['mbstring'] === true) {
5233
      return \mb_strstr($haystack, $needle, $before_needle, $encoding);
@@ 5595-5601 (lines=7) @@
5592
      return \substr($str, $offset, $length ?? $str_length);
5593
    }
5594
5595
    if (
5596
        $encoding !== 'UTF-8'
5597
        &&
5598
        self::$SUPPORT['mbstring'] === false
5599
    ) {
5600
      \trigger_error('UTF8::substr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5601
    }
5602
5603
    if (self::$SUPPORT['mbstring'] === true) {
5604
      return \mb_substr($str, $offset, $length, $encoding);
@@ 5752-5758 (lines=7) @@
5749
      self::checkForSupport();
5750
    }
5751
5752
    if (
5753
        $encoding !== 'UTF-8'
5754
        &&
5755
        self::$SUPPORT['mbstring'] === false
5756
    ) {
5757
      \trigger_error('UTF8::substr_count() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5758
    }
5759
5760
    if (self::$SUPPORT['mbstring'] === true) {
5761
      return \mb_substr_count($haystack, $needle, $encoding);