Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Public Attributes | List of all members
WikiDiff Class Reference

Class representing a 'diff' between two sequences of strings. More...

Inheritance diagram for WikiDiff:
MappedWikiDiff WordLevelWikiDiff

Public Member Functions

 __construct ($from_lines, $to_lines)
 Constructor. More...
 
 _check ($from_lines, $to_lines)
 Check a WikiDiff for validity. More...
 
 closing ()
 Get the closing set of lines. More...
 
 isEmpty ()
 Check for empty diff. More...
 
 lcs ()
 Compute the length of the Longest Common Subsequence (LCS). More...
 
 orig ()
 Get the original set of lines. More...
 
 reverse ()
 Compute reversed WikiDiff. More...
 
 WikiDiff ($from_lines, $to_lines)
 Old syntax of class constructor. More...
 

Public Attributes

 $edits
 

Detailed Description

Class representing a 'diff' between two sequences of strings.

Constructor & Destructor Documentation

◆ __construct()

WikiDiff::__construct (   $from_lines,
  $to_lines 
)

Constructor.

Computes diff between sequences of strings.

Parameters
$from_linesarray An array of strings. (Typically these are lines from a file.)
$to_linesarray An array of strings.

Reimplemented in WordLevelWikiDiff.

Member Function Documentation

◆ _check()

WikiDiff::_check (   $from_lines,
  $to_lines 
)

Check a WikiDiff for validity.

This is here only for debugging purposes.

◆ closing()

WikiDiff::closing ( )

Get the closing set of lines.

This reconstructs the $to_lines parameter passed to the constructor.

Return values
arrayThe sequence of strings.

Reimplemented in WordLevelWikiDiff.

◆ isEmpty()

WikiDiff::isEmpty ( )

Check for empty diff.

Return values
boolTrue iff two sequences were identical.

◆ lcs()

WikiDiff::lcs ( )

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

This is mostly for diagnostic purposed.

Return values
intThe length of the LCS.

◆ orig()

WikiDiff::orig ( )

Get the original set of lines.

This reconstructs the $from_lines parameter passed to the constructor.

Return values
arrayThe original sequence of strings.

Reimplemented in WordLevelWikiDiff.

◆ reverse()

WikiDiff::reverse ( )

Compute reversed WikiDiff.

SYNOPSIS:

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

Return values
objectA WikiDiff object representing the inverse of the original diff.

◆ WikiDiff()

WikiDiff::WikiDiff (   $from_lines,
  $to_lines 
)

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated:
since Moodle 3.1

The documentation for this class was generated from the following file: