PHP Class DiffMatchPatch\Patch

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

Protected Properties

Свойство Type Description
$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

Méthodes publiques

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

Méthodes protégées

Méthode Description
deepCopy ( PatchObject[] $patches ) : PatchObject[] Given an array of patches, return another array that is identical.
getDiff ( ) : Diff
getMatch ( ) : Match

Method Details

__construct() public méthode

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

addContext() public méthode

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() public méthode

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.
Résultat string The padding string added to each side.

apply() public méthode

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.
Résultat array Two element Array, containing the new text and an array of boolean values.

deepCopy() protected méthode

Given an array of patches, return another array that is identical.
protected deepCopy ( PatchObject[] $patches ) : PatchObject[]
$patches PatchObject[] Array of PatchObjects.
Résultat PatchObject[] Array of PatchObjects.

fromText() public méthode

Parse a textual representation of patches and return a list of patch objects.
public fromText ( string $patchText ) : PatchObject[]
$patchText string Text representation of patches.
Résultat PatchObject[] Array of PatchObjects.

getDeleteTreshold() public méthode

public getDeleteTreshold ( ) : float
Résultat float

getDiff() protected méthode

protected getDiff ( ) : Diff
Résultat Diff

getMargin() public méthode

public getMargin ( ) : integer
Résultat integer

getMatch() protected méthode

protected getMatch ( ) : Match
Résultat Match

make() public méthode

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).
Résultat PatchObject[] Array of PatchObjects.

setDeleteTreshold() public méthode

public setDeleteTreshold ( float $deleteTreshold )
$deleteTreshold float

setMargin() public méthode

public setMargin ( integer $margin )
$margin integer

splitMax() public méthode

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() public méthode

Take a list of patches and return a textual representation.
public toText ( PatchObject[] $patches ) : string
$patches PatchObject[] Array of PatchObjects.
Résultat string Text representation of patches.

Property Details

$deleteTreshold protected_oe property

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_oe property

protected Diff,diffmatchpatch $diff
Résultat Diff

$margin protected_oe property

Chunk size for context length.
protected $margin

$match protected_oe property

protected Match,diffmatchpatch $match
Résultat Match