class mapped_diff extends diff
Properties
| array | $_edits | Array of changes. |
Methods
|
diff($from_content, $to_content, $preserve_cr = true)
Computes diffs between sequences of strings. |
from diff | |
|
get_diff()
Returns the array of differences. |
from diff | |
| integer |
count_added_lines()
returns the number of new (added) lines in a given diff. |
from diff |
| integer |
count_deleted_lines()
Returns the number of deleted (removed) lines in a given diff. |
from diff |
| diff |
reverse()
Computes a reversed diff. |
from diff |
| boolean |
is_empty()
Checks for an empty diff. |
from diff |
| integer |
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, integer $key)
Removes trailing newlines from a line of text. |
from diff | |
|
_check($from_lines, $to_lines)
Checks a diff for validity. |
from diff | |
|
mapped_diff(array $from_lines, array $to_lines, array $mapped_from_lines, array $mapped_to_lines)
Computes a diff between sequences of strings. |
Details
in diff at line 49
public
diff($from_content, $to_content, $preserve_cr = true)
Computes diffs between sequences of strings.
in diff at line 58
public
get_diff()
Returns the array of differences.
in diff at line 70
public integer
count_added_lines()
returns the number of new (added) lines in a given diff.
in diff at line 93
public integer
count_deleted_lines()
Returns the number of deleted (removed) lines in a given diff.
in diff at line 122
public diff
reverse()
Computes a reversed diff.
Example:
$diff = new diff($lines1, $lines2);
$rev = $diff->reverse();
in diff at line 149
public boolean
is_empty()
Checks for an empty diff.
in diff at line 191
public integer
lcs()
Computes the length of the Longest Common Subsequence (LCS).
This is mostly for diagnostic purposes.
in diff at line 214
public array
get_original()
Gets the original set of lines.
This reconstructs the $from_lines parameter passed to the constructor.
in diff at line 237
public array
get_final()
Gets the final set of lines.
This reconstructs the $to_lines parameter passed to the constructor.
in diff at line 259
public
trim_newlines(string $line, integer $key)
Removes trailing newlines from a line of text.
This is meant to be used with array_walk().
in diff at line 269
public
_check($from_lines, $to_lines)
Checks a diff for validity.
This is here only for debugging purposes.
at line 329
public
mapped_diff(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.