class mapped_diff extends diff

Properties

array $_edits

Array of changes.

from  diff

Methods

__construct(array $from_lines, array $to_lines, array $mapped_from_lines, array $mapped_to_lines)

Computes a diff between sequences of strings.

get_diff()

Returns the array of differences.

from  diff
int
count_added_lines()

returns the number of new (added) lines in a given diff.

from  diff
int
count_deleted_lines()

Returns the number of deleted (removed) lines in a given diff.

from  diff
reverse()

Computes a reversed diff.

from  diff
bool
is_empty()

Checks for an empty diff.

from  diff
int
lcs()

Computes the length of the Longest Common Subsequence (LCS).

from  diff
array
get_original()

Gets the original set of lines.

from  diff
array
get_final()

Gets the final set of lines.

from  diff
trim_newlines(string $line, int $key)

Removes trailing newlines from a line of text. This is meant to be used with array_walk().

from  diff
_check($from_lines, $to_lines)

Checks a diff for validity.

from  diff

Details

at line 339
__construct(array $from_lines, array $to_lines, array $mapped_from_lines, array $mapped_to_lines)

Computes a diff between sequences of strings.

This can be used to compute things like case-insensitve diffs, or diffs which ignore changes in white-space.

Parameters

array $from_lines

An array of strings.

array $to_lines

An array of strings.

array $mapped_from_lines

This array should have the same size number of elements as $from_lines. The elements in $mapped_from_lines and $mapped_to_lines are what is actually compared when computing the diff.

array $mapped_to_lines

This array should have the same number of elements as $to_lines.

in diff at line 62
get_diff()

Returns the array of differences.

in diff at line 74
int count_added_lines()

Since: Text_Diff 1.1.0

returns the number of new (added) lines in a given diff.

Return Value

int

The number of new lines

in diff at line 97
int count_deleted_lines()

Since: Text_Diff 1.1.0

Returns the number of deleted (removed) lines in a given diff.

Return Value

int

The number of deleted lines

in diff at line 126
diff reverse()

Computes a reversed diff.

Example:

$diff = new diff($lines1, $lines2);
$rev = $diff->reverse();

Return Value

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.

in diff at line 153
bool is_empty()

Checks for an empty diff.

Return Value

bool

True if two sequences were identical.

in diff at line 201
int lcs()

Computes the length of the Longest Common Subsequence (LCS).

This is mostly for diagnostic purposes.

Return Value

int

The length of the LCS.

in diff at line 224
array get_original()

Gets the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

Return Value

array

The original sequence of strings.

in diff at line 247
array get_final()

Gets the final set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

Return Value

array

The sequence of strings.

in diff at line 269
trim_newlines(string $line, int $key)

Removes trailing newlines from a line of text. This is meant to be used with array_walk().

Parameters

string $line

The line to trim.

int $key

The index of the line in the array. Not used.

in diff at line 279
_check($from_lines, $to_lines)

Checks a diff for validity.

This is here only for debugging purposes.

Parameters

$from_lines
$to_lines