function WordLevelDiff::__construct

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Component/Diff/WordLevelDiff.php \Drupal\Component\Diff\WordLevelDiff::__construct()
  2. 10 core/lib/Drupal/Component/Diff/WordLevelDiff.php \Drupal\Component\Diff\WordLevelDiff::__construct()
  3. 11.x core/lib/Drupal/Component/Diff/WordLevelDiff.php \Drupal\Component\Diff\WordLevelDiff::__construct()

Constructor.

Computes diff between sequences of strings.

This can be used to compute things like case-insensitive diffs, or diffs which ignore changes in white-space.

Parameters

array $from_lines: An array of strings. (Typically these are lines from a file.)

array $to_lines: An array of strings.

array $mapped_from_lines: This array should have the same size number of elements as $from_lines. The elements in $mapped_from_lines and $mapped_to_lines are what is actually compared when computing the diff.

array $mapped_to_lines: This array should have the same number of elements as $to_lines.

Overrides MappedDiff::__construct

File

core/lib/Drupal/Component/Diff/WordLevelDiff.php, line 16

Class

WordLevelDiff
@todo document @private @subpackage DifferenceEngine

Namespace

Drupal\Component\Diff

Code

public function __construct($orig_lines, $closing_lines) {
    [
        $orig_words,
        $orig_stripped,
    ] = $this->_split($orig_lines);
    [
        $closing_words,
        $closing_stripped,
    ] = $this->_split($closing_lines);
    parent::__construct($orig_words, $closing_words, $orig_stripped, $closing_stripped);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.