PHP Class DiffMatchPatch\DiffToolkit

Author: Neil Fraser ([email protected])
Author: Daniil Skrobov ([email protected])
Datei anzeigen Open project: yetanotherape/diff-match-patch

Public Methods

Method Description
charsToLines ( array &$diffs, array $lineArray ) Rehydrate the text in a diff from a string of line hashes to real lines of text.
commonPrefix ( string $text1, string $text2 ) : integer Determine the common prefix of two strings.
commonSuffix ( string $text1, string $text2 ) : integer Determine the common suffix of two strings.
commontOverlap ( string $text1, string $text2 ) : integer Determine if the suffix of one string is the prefix of another.
halfMatch ( string $text1, string $text2 ) : null | array Do the two texts share a substring which is at least half the length of the longer text? This speedup can produce non-minimal diffs.
linesToChars ( string $text1, string $text2 ) : array Split two texts into an array of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.

Protected Methods

Method Description
halfMatchI ( string $longtext, string $shorttext, integer $i ) : null | array Does a substring of shorttext exist within longtext such that the substring is at least half the length of longtext?
linesToCharsMunge ( string $text, array &$lineArray, array &$lineHash ) : string Split a text into an array of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.

Method Details

charsToLines() public method

Modifies $diffs. TODO try to fix it!
public charsToLines ( array &$diffs, array $lineArray )
$diffs array Array of diff arrays.
$lineArray array Array of unique strings.

commonPrefix() public method

Determine the common prefix of two strings.
public commonPrefix ( string $text1, string $text2 ) : integer
$text1 string First string.
$text2 string Second string.
return integer The number of characters common to the start of each string.

commonSuffix() public method

Determine the common suffix of two strings.
public commonSuffix ( string $text1, string $text2 ) : integer
$text1 string First string.
$text2 string Second string.
return integer The number of characters common to the end of each string.

commontOverlap() public method

Determine if the suffix of one string is the prefix of another.
public commontOverlap ( string $text1, string $text2 ) : integer
$text1 string First string.
$text2 string Second string.
return integer The number of characters common to the end of the first string and the start of the second string.

halfMatch() public method

Do the two texts share a substring which is at least half the length of the longer text? This speedup can produce non-minimal diffs.
public halfMatch ( string $text1, string $text2 ) : null | array
$text1 string First string.
$text2 string Second string.
return null | array Five element array, containing the prefix of text1, the suffix of text1, the prefix of text2, the suffix of text2 and the common middle. Or null if there was no match.

halfMatchI() protected method

Does a substring of shorttext exist within longtext such that the substring is at least half the length of longtext?
protected halfMatchI ( string $longtext, string $shorttext, integer $i ) : null | array
$longtext string Longer string.
$shorttext string Shorter string.
$i integer Start index of quarter length substring within longtext.
return null | array Five element array, containing the prefix of longtext, the suffix of longtext, the prefix of shorttext, the suffix of shorttext and the common middle. Or null if there was no match.

linesToChars() public method

Split two texts into an array of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.
public linesToChars ( string $text1, string $text2 ) : array
$text1 string First string.
$text2 string Second string.
return array Three element array, containing the encoded text1, the encoded text2 and the array of unique strings. The zeroth element of the array of unique strings is intentionally blank.

linesToCharsMunge() protected method

Modifies $lineArray and $lineHash. TODO try to fix it!
protected linesToCharsMunge ( string $text, array &$lineArray, array &$lineHash ) : string
$text string String to encode.
$lineArray array
$lineHash array
return string Encoded string.