PHP 클래스 DiffMatchPatch\DiffMatchPatch

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.
저자: Neil Fraser ([email protected])
저자: Daniil Skrobov ([email protected])
파일 보기 프로젝트 열기: yetanotherape/diff-match-patch 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$diff Diff
$match Match
$patch Patch

공개 메소드들

메소드 설명
__construct ( )
__get ( string $name ) : float Proxy getting properties to real objects.
__set ( string $name, mixed $value ) : float Proxy setting properties to real objects.
diff_cleanupEfficiency ( array &$diffs ) Reduce the number of edits by eliminating operationally trivial equalities.
diff_cleanupSemantic ( array &$diffs ) Reduce the number of edits by eliminating semantically trivial equalities.
diff_levenshtein ( array $diffs ) : integer Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
diff_main ( string $text1, string $text2, boolean $checklines = true ) : array Find the differences between two texts. Simplifies the problem by stripping any common prefix or suffix off the texts before diffing.
diff_prettyHtml ( array $diffs ) : string Convert a diff array into a pretty HTML report.
match_main ( string $text, string $pattern, integer $loc ) : integer Locate the best instance of 'pattern' in 'text' near 'loc'.
patch_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.
patch_fromText ( string $text ) : PatchObject[] Parse a textual representation of patches and return a list of patch objects.
patch_make ( string | array $a, string | array | null $b = null, array | null $c = null ) : PatchObject[] Compute a list of patches to turn text1 into text2.
patch_toText ( PatchObject[] $patches ) : string Take a list of patches and return a textual representation.

메소드 상세

__construct() 공개 메소드

public __construct ( )

__get() 공개 메소드

Proxy getting properties to real objects.
public __get ( string $name ) : float
$name string Property name.
리턴 float

__set() 공개 메소드

Proxy setting properties to real objects.
public __set ( string $name, mixed $value ) : float
$name string Property name.
$value mixed Property value.
리턴 float

diff_cleanupEfficiency() 공개 메소드

Modifies $diffs.
public diff_cleanupEfficiency ( array &$diffs )
$diffs array Array of diff arrays.

diff_cleanupSemantic() 공개 메소드

Modifies $diffs.
public diff_cleanupSemantic ( array &$diffs )
$diffs array Array of diff arrays.

diff_levenshtein() 공개 메소드

Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
public diff_levenshtein ( array $diffs ) : integer
$diffs array Array of diff arrays.
리턴 integer Number of changes.

diff_main() 공개 메소드

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.
리턴 array Array of changes.

diff_prettyHtml() 공개 메소드

Convert a diff array into a pretty HTML report.
public diff_prettyHtml ( array $diffs ) : string
$diffs array Array of diff arrays.
리턴 string HTML representation.

match_main() 공개 메소드

Locate the best instance of 'pattern' in 'text' near 'loc'.
public match_main ( string $text, string $pattern, integer $loc ) : integer
$text string The text to search.
$pattern string The pattern to search for.
$loc integer The location to search around.
리턴 integer Best match index or -1.

patch_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 patch_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.

patch_fromText() 공개 메소드

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.
리턴 PatchObject[] Array of PatchObjects.

patch_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 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).
리턴 PatchObject[] Array of PatchObjects.

patch_toText() 공개 메소드

Take a list of patches and return a textual representation.
public patch_toText ( PatchObject[] $patches ) : string
$patches PatchObject[] Array of PatchObjects.
리턴 string Text representation of patches.

프로퍼티 상세

$diff 보호되어 있는 프로퍼티

protected Diff,diffmatchpatch $diff
리턴 Diff

$match 보호되어 있는 프로퍼티

protected Match,diffmatchpatch $match
리턴 Match

$patch 보호되어 있는 프로퍼티

protected Patch,diffmatchpatch $patch
리턴 Patch