PHP 클래스 Horde_Text_Diff, horde

The original PHP version of this code was written by Geoffrey T. Dairiki , and is used/adapted with his permission. Copyright 2004 Geoffrey T. Dairiki Copyright 2004-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
저자: Geoffrey T. Dairiki ([email protected])
파일 보기 프로젝트 열기: horde/horde 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_edits array Array of changes.

공개 메소드들

메소드 설명
__construct ( string $engine, array $params ) Computes diffs between sequences of strings.
countAddedLines ( ) : integer returns the number of new (added) lines in a given diff.
countDeletedLines ( ) : integer Returns the number of deleted (removed) lines in a given diff.
getDiff ( ) Returns the array of differences.
getFinal ( ) : array Gets the final set of lines.
getOriginal ( ) : array Gets the original set of lines.
isEmpty ( ) : boolean Checks for an empty diff.
lcs ( ) : integer Computes the length of the Longest Common Subsequence (LCS).
reverse ( ) : Horde_Text_Diff Computes a reversed diff.
trimNewlines ( string &$line, integer $key ) Removes trailing newlines from a line of text. This is meant to be used with array_walk().

보호된 메소드들

메소드 설명
_check ( $from_lines, $to_lines ) Checks a diff for validity.

메소드 상세

__construct() 공개 메소드

Computes diffs between sequences of strings.
public __construct ( string $engine, array $params )
$engine string Name of the diffing engine to use. 'auto' will automatically select the best.
$params array Parameters to pass to the diffing engine. Normally an array of two arrays, each containing the lines from a file.

_check() 보호된 메소드

This is here only for debugging purposes.
protected _check ( $from_lines, $to_lines )

countAddedLines() 공개 메소드

returns the number of new (added) lines in a given diff.
public countAddedLines ( ) : integer
리턴 integer The number of new lines

countDeletedLines() 공개 메소드

Returns the number of deleted (removed) lines in a given diff.
public countDeletedLines ( ) : integer
리턴 integer The number of deleted lines

getDiff() 공개 메소드

Returns the array of differences.
public getDiff ( )

getFinal() 공개 메소드

This reconstructs the $to_lines parameter passed to the constructor.
public getFinal ( ) : array
리턴 array The sequence of strings.

getOriginal() 공개 메소드

This reconstructs the $from_lines parameter passed to the constructor.
public getOriginal ( ) : array
리턴 array The original sequence of strings.

isEmpty() 공개 메소드

Checks for an empty diff.
public isEmpty ( ) : boolean
리턴 boolean True if two sequences were identical.

lcs() 공개 메소드

This is mostly for diagnostic purposes.
public lcs ( ) : integer
리턴 integer The length of the LCS.

reverse() 공개 메소드

Example: $diff = new Horde_Text_Diff($lines1, $lines2); $rev = $diff->reverse();
public reverse ( ) : Horde_Text_Diff
리턴 Horde_Text_Diff A Diff object representing the inverse of the original diff. Note that we purposely don't return a reference here, since this essentially is a clone() method.

trimNewlines() 공개 정적인 메소드

Removes trailing newlines from a line of text. This is meant to be used with array_walk().
public static trimNewlines ( string &$line, integer $key )
$line string The line to trim.
$key integer The index of the line in the array. Not used.

프로퍼티 상세

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

Array of changes.
protected array $_edits
리턴 array