Text_Diff::__construct()publicWP 1.0

Computes diffs between sequences of strings.

Method of the class: Text_Diff{}

No Hooks.

Return

null. Nothing (null).

Usage

$Text_Diff = new Text_Diff();
$Text_Diff->__construct( $engine, $params );
$engine(string) (required)
Name of the diffing engine to use. 'auto' will automatically select the best.
$params(array) (required)
Parameters to pass to the diffing engine. Normally an array of two arrays, each containing the lines from a file.

Text_Diff::__construct() code WP 6.5.2

function __construct( $engine, $params )
{
    // Backward compatibility workaround.
    if (!is_string($engine)) {
        $params = array($engine, $params);
        $engine = 'auto';
    }

    if ($engine == 'auto') {
        $engine = extension_loaded('xdiff') ? 'xdiff' : 'native';
    } else {
        $engine = basename($engine);
    }

    // WP #7391
    require_once dirname(__FILE__).'/Diff/Engine/' . $engine . '.php';
    $class = 'Text_Diff_Engine_' . $engine;
    $diff_engine = new $class();

    $this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params);
}