PHP Class Diff

Inheritance: extends CI_Model
Mostra file Open project: kylekatarnls/jade-php Class Usage Examples

Public Methods

Method Description
compare ( $string1, $string2, $compareCharacters = false, $ignoreIndent = true ) * Returns the diff for two strings. The return value is an array, each of whose values is an array containing two values: a line (or character, if $compareCharacters is true), and one of the constants DIFF::UNMODIFIED (the line or character is in both strings), DIFF::DELETED (the line or character is only in the first string), and DIFF::INSERTED (the line or character is only in the second string). The parameters are:
compareFiles ( $file1, $file2, $compareCharacters = false ) * Returns the diff for two files. The parameters are:
toHTML ( $diff, $separator = '<br>' ) * Returns a diff as an HTML string, where unmodified lines are contained within 'span' elements, deletions are contained within 'del' elements, and insertions are contained within 'ins' elements. The parameters are:
toString ( $diff, $separator = " " ) * Returns a diff as a string, where unmodified lines are prefixed by ' ', deletions are prefixed by '- ', and insertions are prefixed by '+ '. The parameters are:
toTable ( $diff, $indentation = '', $separator = '<br>' ) * Returns a diff as an HTML table. The parameters are:

Protected Methods

Method Description
compareLine ( $line1, $line2, $ignoreIndent = true )
ignoreIndent ( $line )

Private Methods

Method Description
computeTable ( $sequence1, $sequence2, $start, $end1, $end2, $ignoreIndent = true ) * Returns the table of longest common subsequence lengths for the specified sequences. The parameters are:
generatePartialDiff ( $table, $sequence1, $sequence2, $start, $ignoreIndent = true ) * Returns the partial diff for the specificed sequences, in reverse order.
getCellContent ( $diff, $indentation, $separator, &$index, $type ) * Returns the content of the cell, for use in the toTable function. The parameters are:

Method Details

compare() public static method

$string1 - the first string $string2 - the second string $compareCharacters - true to compare characters, and false to compare lines; this optional parameter defaults to false $ignoreIndent - false to compare also white spaces in the beginning on the line, true to ignore them
public static compare ( $string1, $string2, $compareCharacters = false, $ignoreIndent = true )

compareFiles() public static method

$file1 - the path to the first file $file2 - the path to the second file $compareCharacters - true to compare characters, and false to compare lines; this optional parameter defaults to false
public static compareFiles ( $file1, $file2, $compareCharacters = false )

compareLine() protected static method

protected static compareLine ( $line1, $line2, $ignoreIndent = true )

ignoreIndent() protected static method

protected static ignoreIndent ( $line )

toHTML() public static method

$diff - the diff array $separator - the separator between lines; this optional parameter defaults to '
'
public static toHTML ( $diff, $separator = '<br>' )

toString() public static method

$diff - the diff array $separator - the separator between lines; this optional parameter defaults to "\n"
public static toString ( $diff, $separator = " " )

toTable() public static method

$diff - the diff array $indentation - indentation to add to every line of the generated HTML; this optional parameter defaults to '' $separator - the separator between lines; this optional parameter defaults to '
'
public static toTable ( $diff, $indentation = '', $separator = '<br>' )