You are here

public function HWLDFWordAccumulator::addWords in Service Container 7

Same name and namespace in other branches
  1. 7.2 lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php \Drupal\Component\Diff\Engine\HWLDFWordAccumulator::addWords()

File

lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php, line 62
Contains \Drupal\Component\Diff\Engine\HWLDFWordAccumulator.

Class

HWLDFWordAccumulator
@todo document @private @subpackage DifferenceEngine

Namespace

Drupal\Component\Diff\Engine

Code

public function addWords($words, $tag = '') {
  if ($tag != $this->tag) {
    $this
      ->_flushGroup($tag);
  }
  foreach ($words as $word) {

    // new-line should only come as first char of word.
    if ($word == '') {
      continue;
    }
    if ($word[0] == "\n") {
      $this
        ->_flushLine($tag);
      $word = Unicode::substr($word, 1);
    }
    assert(!strstr($word, "\n"));
    $this->group .= $word;
  }
}