Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 1935-1946 (lines=12) @@
1932
            $buf .= $cc1 . $cc2;
1933
          }
1934
1935
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
1936
1937
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
1938
            $buf .= $c1 . $c2 . $c3;
1939
            $i += 2;
1940
          } else { // not valid UTF8 - convert it
1941
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
1942
            $cc2 = ($c1 & "\x3f") | "\x80";
1943
            $buf .= $cc1 . $cc2;
1944
          }
1945
1946
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
1947
1948
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
1949
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 1948-1955 (lines=8) @@
1945
1946
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
1947
1948
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
1949
            $buf .= $c1 . $c2 . $c3 . $c4;
1950
            $i += 3;
1951
          } else { // not valid UTF8 - convert it
1952
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
1953
            $cc2 = ($c1 & "\x3f") | "\x80";
1954
            $buf .= $cc1 . $cc2;
1955
          }
1956
1957
        } else { // doesn't look like UTF8, but should be converted
1958
          $cc1 = (chr(ord($c1) / 64) | "\xc0");