diff --git a/MD_STD.php b/MD_STD.php index bb3838b..327be44 100644 --- a/MD_STD.php +++ b/MD_STD.php @@ -430,4 +430,22 @@ final class MD_STD { } } + + /** + * Wrapper around levenshtein(), that only compares the first 250 + * characters (levenshtein can't handle more than 255). + * + * @param string $str1 First string. + * @param string $str2 Second string. + * + * @return integer + */ + public static function levenshtein(string $str1, string $str2):int { + + if (\strlen($str1) > 250) $str1 = \substr($str1, 0, 250); + if (\strlen($str2) > 250) $str2 = \substr($str2, 0, 250); + + return \levenshtein($str1, $str2); + + } }