PHP Класс DiffMatchPatch\Patch

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

Защищенные свойства (Protected)

Свойство Тип Описание
$deleteTreshold When deleting a large block of text (over ~64 characters), how close do the contents have to be to match the expected contents. (0.0 = perfection, 1.0 = very loose). Note that Match->threshold controls how closely the end points of a delete need to match.
$diff Diff
$margin Chunk size for context length.
$match Match

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

Метод Описание
__construct ( Diff $diff = null, Match $match = null )
addContext ( PatchObject $patch, string $text ) Increase the context until it is unique, but don't let the pattern expand beyond Match->maxBits.
addPadding ( PatchObject[] &$patches ) : string Add some padding on text start and end so that edges can match something.
apply ( PatchObject[] $patches, string $text ) : array Merge a set of patches onto the text. Return a patched text, as well as a list of true/false values indicating which patches were applied.
fromText ( string $patchText ) : PatchObject[] Parse a textual representation of patches and return a list of patch objects.
getDeleteTreshold ( ) : float
getMargin ( ) : integer
make ( string | array $a, string | array | null $b = null, array | null $c = null ) : PatchObject[] Compute a list of patches to turn text1 into text2.
setDeleteTreshold ( float $deleteTreshold )
setMargin ( integer $margin )
splitMax ( PatchObject[] &$patches ) Look through the patches and break up any which are longer than the maximum limit of the match algorithm.
toText ( PatchObject[] $patches ) : string Take a list of patches and return a textual representation.

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

Метод Описание
deepCopy ( PatchObject[] $patches ) : PatchObject[] Given an array of patches, return another array that is identical.
getDiff ( ) : Diff
getMatch ( ) : Match

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

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

public __construct ( Diff $diff = null, Match $match = null )
$diff Diff
$match Match

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

Increase the context until it is unique, but don't let the pattern expand beyond Match->maxBits.
public addContext ( PatchObject $patch, string $text )
$patch PatchObject The patch to grow.
$text string Source text.

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

Intended to be called only from within patch_apply. Modifies $patches. TODO try to fix it!
public addPadding ( PatchObject[] &$patches ) : string
$patches PatchObject[] Array of PatchObjects.
Результат string The padding string added to each side.

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

Merge a set of patches onto the text. Return a patched text, as well as a list of true/false values indicating which patches were applied.
public apply ( PatchObject[] $patches, string $text ) : array
$patches PatchObject[] Array of PatchObjects.
$text string Old text.
Результат array Two element Array, containing the new text and an array of boolean values.

deepCopy() защищенный Метод

Given an array of patches, return another array that is identical.
protected deepCopy ( PatchObject[] $patches ) : PatchObject[]
$patches PatchObject[] Array of PatchObjects.
Результат PatchObject[] Array of PatchObjects.

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

Parse a textual representation of patches and return a list of patch objects.
public fromText ( string $patchText ) : PatchObject[]
$patchText string Text representation of patches.
Результат PatchObject[] Array of PatchObjects.

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

public getDeleteTreshold ( ) : float
Результат float

getDiff() защищенный Метод

protected getDiff ( ) : Diff
Результат Diff

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

public getMargin ( ) : integer
Результат integer

getMatch() защищенный Метод

protected getMatch ( ) : Match
Результат Match

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

Use diffs if provided, otherwise compute it ourselves. There are four ways to call this function, depending on what data is available to the caller: Method 1: a = text1, b = text2 Method 2: a = diffs Method 3 (optimal): a = text1, b = diffs Method 4 (deprecated, use method 3): a = text1, b = text2, c = diffs
public make ( string | array $a, string | array | null $b = null, array | null $c = null ) : PatchObject[]
$a string | array text1 (methods 1,3,4) or Array of diff arrays for text1 to text2 (method 2).
$b string | array | null text2 (methods 1,4) or Array of diff arrays for text1 to text2 (method 3) or null (method 2).
$c array | null Array of diff arrays for text1 to text2 (method 4) or null (methods 1,2,3).
Результат PatchObject[] Array of PatchObjects.

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

public setDeleteTreshold ( float $deleteTreshold )
$deleteTreshold float

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

public setMargin ( integer $margin )
$margin integer

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

Intended to be called only from within apply(). Modifies $patches. TODO try to fix it!
public splitMax ( PatchObject[] &$patches )
$patches PatchObject[] Array of PatchObjects.

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

Take a list of patches and return a textual representation.
public toText ( PatchObject[] $patches ) : string
$patches PatchObject[] Array of PatchObjects.
Результат string Text representation of patches.

Описание свойств

$deleteTreshold защищенное свойство

When deleting a large block of text (over ~64 characters), how close do the contents have to be to match the expected contents. (0.0 = perfection, 1.0 = very loose). Note that Match->threshold controls how closely the end points of a delete need to match.
protected $deleteTreshold

$diff защищенное свойство

protected Diff,diffmatchpatch $diff
Результат Diff

$margin защищенное свойство

Chunk size for context length.
protected $margin

$match защищенное свойство

protected Match,diffmatchpatch $match
Результат Match