Text_Diff
[ class tree: Text_Diff ] [ index: Text_Diff ] [ all elements ]

Class: Text_Diff

Source Location: /Text_Diff-1.2.1/Text/Diff.php

Class Overview


General API for generating and formatting diffs - the differences between two sequences of strings.


Author(s):

Methods


Child classes:

Text_Diff3
A class for computing three way diffs.
Text_MappedDiff
Text_Diff_ThreeWay
A class for computing three way diffs.
Text_Diff_Mapped
$Horde: framework/Text_Diff/Diff/Mapped.php,v 1.3.2.4 2009/01/06 15:23:41 jan Exp $

Inherited Variables

Inherited Methods


Class Details

[line 20]
General API for generating and formatting diffs - the differences between two sequences of strings.

The original PHP version of this code was written by Geoffrey T. Dairiki <dairiki@dairiki.org>, and is used/adapted with his permission.

$Horde: framework/Text_Diff/Diff.php,v 1.11.2.12 2009/01/06 15:23:41 jan Exp $

Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org> Copyright 2004-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://opensource.org/licenses/lgpl-license.php.



[ Top ]


Method Detail

__construct (Constructor)   [line 38]

Text_Diff __construct( string $engine, array $params)

Computes diffs between sequences of strings.

Overridden in child classes as:

Text_Diff3::__construct()
Computes diff between 3 sequences of strings.
Text_Diff_ThreeWay::__construct()
Computes diff between 3 sequences of strings.
Text_Diff_Mapped::__construct()
Computes a diff between sequences of strings.

Parameters:

string   $engine   —  Name of the diffing engine to use. 'auto' will automatically select the best.
array   $params   —  Parameters to pass to the diffing engine. Normally an array of two arrays, each containing the lines from a file.

[ Top ]

countAddedLines   [line 75]

integer countAddedLines( )

returns the number of new (added) lines in a given diff.
  • Return: The number of new lines
  • Since: Text_Diff 1.1.0
  • Since: Horde 3.2

[ Top ]

countDeletedLines   [line 95]

integer countDeletedLines( )

Returns the number of deleted (removed) lines in a given diff.
  • Return: The number of deleted lines
  • Since: Text_Diff 1.1.0
  • Since: Horde 3.2

[ Top ]

getDiff   [line 62]

void getDiff( )

Returns the array of differences.

[ Top ]

getFinal   [line 193]

array getFinal( )

Gets the final set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

  • Return: The sequence of strings.

[ Top ]

getOriginal   [line 175]

array getOriginal( )

Gets the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

  • Return: The original sequence of strings.

[ Top ]

isEmpty   [line 140]

boolean isEmpty( )

Checks for an empty diff.
  • Return: True if two sequences were identical.

[ Top ]

lcs   [line 157]

integer lcs( )

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

This is mostly for diagnostic purposes.

  • Return: The length of the LCS.

[ Top ]

reverse   [line 121]

Text_Diff reverse( )

Computes a reversed diff.

Example:

  1.  $diff = new Text_Diff($lines1$lines2);
  2.  $rev $diff->reverse();

  • Return: 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.

[ Top ]

trimNewlines   [line 211]

void trimNewlines( &$line, integer $key, string $line)

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

Parameters:

string   $line   —  The line to trim.
integer   $key   —  The index of the line in the array. Not used.
   &$line   — 

[ Top ]

_getTempDir   [line 226]

string _getTempDir( )

Determines the location of the system temporary directory.
  • Return: A directory name which can be used for temp files. Returns false if one could not be found.
  • Access: protected

[ Top ]


Documentation generated on Mon, 11 Mar 2019 16:03:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.