Computes the difference between two texts to create a patch. Applies the patch onto another text,
allowing for errors.
This class implements the same API as all other google-diff-match-patch libs. It was created for
compatibility reason only.
diff_main()
public method
Find the differences between two texts. Simplifies the problem by
stripping any common prefix or suffix off the texts before diffing.
public diff_main ( string $text1, string $text2, boolean $checklines = true ) : array |
$text1 |
string |
Old string to be diffed. |
$text2 |
string |
New string to be diffed. |
$checklines |
boolean |
Optional speedup flag. If present and false, then don't run
a line-level diff first to identify the changed areas.
Defaults to true, which does a faster, slightly less optimal diff. |
return |
array |
Array of changes. |
match_main()
public method
Locate the best instance of 'pattern' in 'text' near 'loc'.
patch_fromText()
public method
Parse a textual representation of patches and return a list of patch objects.
public patch_fromText ( string $text ) : PatchObject[] |
$text |
string |
Text representation of patches. |
return |
PatchObject[] |
Array of PatchObjects. |
patch_make()
public method
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 patch_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). |
return |
PatchObject[] |
Array of PatchObjects. |
patch_toText()
public method
Take a list of patches and return a textual representation.
public patch_toText ( PatchObject[] $patches ) : string |
$patches |
PatchObject[] |
Array of PatchObjects. |
return |
string |
Text representation of patches. |