Code Duplication    Length = 18-19 lines in 2 locations

src/voku/helper/Bootup.php 1 location

@@ 183-200 (lines=18) @@
180
      $s = str_replace(array("\r\n", "\r"), "\n", $s);
181
    }
182
183
    if (preg_match('/[\x80-\xFF]/', $s)) {
184
      if (Normalizer::isNormalized($s, $normalization_form)) {
185
        $n = '-';
186
      } else {
187
        $n = Normalizer::normalize($s, $normalization_form);
188
        if (isset($n[0])) {
189
          $s = $n;
190
        } else {
191
          $s = UTF8::encode('UTF-8', $s);
192
        }
193
      }
194
195
      if ($s[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $s)) {
196
        // Prevent leading combining chars
197
        // for NFC-safe concatenations.
198
        $s = $leading_combining . $s;
199
      }
200
    }
201
202
    return $s;
203
  }

src/voku/helper/UTF8.php 1 location

@@ 2668-2686 (lines=19) @@
2665
          // Workaround https://bugs.php.net/65732
2666
          $var = str_replace(array("\r\n", "\r"), "\n", $var);
2667
        }
2668
        if (preg_match('/[\x80-\xFF]/', $var)) {
2669
          if (Normalizer::isNormalized($var, $normalization_form)) {
2670
            $n = '-';
2671
          } else {
2672
            $n = Normalizer::normalize($var, $normalization_form);
2673
2674
            if (isset($n[0])) {
2675
              $var = $n;
2676
            } else {
2677
              $var = self::encode('UTF-8', $var);
2678
            }
2679
2680
          }
2681
          if ($var[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $var)) {
2682
            // Prevent leading combining chars
2683
            // for NFC-safe concatenations.
2684
            $var = $leading_combining . $var;
2685
          }
2686
        }
2687
        break;
2688
    }
2689