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])
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_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