/** * * @param string $a * @param string $b * @param float $divisor for calculating the minimum required percentage of overlap * @return string a copy of $a, where the overlap is indicated with <overlap></overlap> * tags */ public static function overlap($a, $b, $divisor = 3.0) { self::$divisor = $divisor; if ($a == $b) { return $a; } elseif (empty($a)) { return ''; } elseif (empty($b)) { return $a; } $lcs = StringDiff::longest_common_substring($a, $b); if (empty($lcs)) { return $a; } $atripartite = StringDiff::tripartite($a, $lcs); $btripartite = StringDiff::tripartite($b, $lcs); $headdiff = StringDiff::overlap($atripartite[0], $btripartite[0]); $taildiff = StringDiff::overlap($atripartite[2], $btripartite[2]); return $headdiff . '<overlap>' . $lcs . '</overlap>' . $taildiff; }