PHP Класс DiffMatchPatch\DiffToolkit

Автор: Neil Fraser ([email protected])
Автор: Daniil Skrobov ([email protected])
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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.

Описание методов

charsToLines() публичный Метод

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() публичный Метод

Determine the common prefix of two strings.
public commonPrefix ( string $text1, string $text2 ) : integer
$text1 string First string.
$text2 string Second string.
Результат integer The number of characters common to the start of each string.

commonSuffix() публичный Метод

Determine the common suffix of two strings.
public commonSuffix ( string $text1, string $text2 ) : integer
$text1 string First string.
$text2 string Second string.
Результат integer The number of characters common to the end of each string.

commontOverlap() публичный Метод

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.
Результат integer The number of characters common to the end of the first string and the start of the second string.

halfMatch() публичный Метод

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.
Результат 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() защищенный Метод

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.
Результат 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() публичный Метод

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.
Результат 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() защищенный Метод

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
Результат string Encoded string.