PHP Class DiffMatchPatch\DiffToolkit

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

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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 méthode

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

commonSuffix() public méthode

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

commontOverlap() public méthode

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.
Résultat integer The number of characters common to the end of the first string and the start of the second string.

halfMatch() public méthode

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.
Résultat 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 méthode

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.
Résultat 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 méthode

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.
Résultat 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 méthode

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
Résultat string Encoded string.