Code Duplication    Length = 7-9 lines in 9 locations

src/voku/helper/UTF8.php 9 locations

@@ 393-401 (lines=9) @@
390
      $encoding = self::normalize_encoding($encoding, 'UTF-8');
391
    }
392
393
    if (
394
        $encoding !== 'UTF-8'
395
        &&
396
        $encoding !== 'WINDOWS-1252'
397
        &&
398
        self::$SUPPORT['mbstring'] === false
399
    ) {
400
      \trigger_error('UTF8::chr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
401
    }
402
403
    $cacheKey = $code_point . $encoding;
404
    if (isset($CHAR_CACHE[$cacheKey]) === true) {
@@ 809-817 (lines=9) @@
806
        return self::to_iso8859($str);
807
      }
808
809
      if (
810
          $encoding !== 'UTF-8'
811
          &&
812
          $encoding !== 'WINDOWS-1252'
813
          &&
814
          self::$SUPPORT['mbstring'] === false
815
      ) {
816
        \trigger_error('UTF8::encode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
817
      }
818
819
      $strEncoded = \mb_convert_encoding(
820
          $str,
@@ 1655-1663 (lines=9) @@
1652
      $flags = ENT_QUOTES | ENT_HTML5;
1653
    }
1654
1655
    if (
1656
        $encoding !== 'UTF-8'
1657
        &&
1658
        $encoding !== 'WINDOWS-1252'
1659
        &&
1660
        self::$SUPPORT['mbstring'] === false
1661
    ) {
1662
      \trigger_error('UTF8::html_entity_decode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
1663
    }
1664
1665
    do {
1666
      $str_compare = $str;
@@ 4610-4616 (lines=7) @@
4607
      self::checkForSupport();
4608
    }
4609
4610
    if (
4611
        $encoding !== 'UTF-8'
4612
        &&
4613
        self::$SUPPORT['mbstring'] === false
4614
    ) {
4615
      \trigger_error('UTF8::stristr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
4616
    }
4617
4618
    if (self::$SUPPORT['mbstring'] === true) {
4619
      return \mb_stristr($haystack, $needle, $before_needle, $encoding);
@@ 5143-5149 (lines=7) @@
5140
      self::checkForSupport();
5141
    }
5142
5143
    if (
5144
        $encoding !== 'UTF-8'
5145
        &&
5146
        self::$SUPPORT['mbstring'] === false
5147
    ) {
5148
      \trigger_error('UTF8::strripos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5149
    }
5150
5151
    if (self::$SUPPORT['mbstring'] === true) {
5152
      return \mb_strripos($haystack, $needle, $offset, $encoding);
@@ 5214-5220 (lines=7) @@
5211
      self::checkForSupport();
5212
    }
5213
5214
    if (
5215
        $encoding !== 'UTF-8'
5216
        &&
5217
        self::$SUPPORT['mbstring'] === false
5218
    ) {
5219
      \trigger_error('UTF8::strrpos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5220
    }
5221
5222
    if (self::$SUPPORT['mbstring'] === true) {
5223
      return \mb_strrpos($haystack, $needle, $offset, $encoding);
@@ 5322-5328 (lines=7) @@
5319
      self::checkForSupport();
5320
    }
5321
5322
    if (
5323
        $encoding !== 'UTF-8'
5324
        &&
5325
        self::$SUPPORT['mbstring'] === false
5326
    ) {
5327
      \trigger_error('UTF8::strstr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5328
    }
5329
5330
    if (self::$SUPPORT['mbstring'] === true) {
5331
      return \mb_strstr($haystack, $needle, $before_needle, $encoding);
@@ 5665-5671 (lines=7) @@
5662
      return \substr($str, $offset, $length ?? $str_length);
5663
    }
5664
5665
    if (
5666
        $encoding !== 'UTF-8'
5667
        &&
5668
        self::$SUPPORT['mbstring'] === false
5669
    ) {
5670
      \trigger_error('UTF8::substr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5671
    }
5672
5673
    if (self::$SUPPORT['mbstring'] === true) {
5674
      return \mb_substr($str, $offset, $length, $encoding);
@@ 5822-5828 (lines=7) @@
5819
      self::checkForSupport();
5820
    }
5821
5822
    if (
5823
        $encoding !== 'UTF-8'
5824
        &&
5825
        self::$SUPPORT['mbstring'] === false
5826
    ) {
5827
      \trigger_error('UTF8::substr_count() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING);
5828
    }
5829
5830
    if (self::$SUPPORT['mbstring'] === true) {
5831
      return \mb_substr_count($haystack, $needle, $encoding);