You are here

public function DiffEntityComparison::processStateLine in Diff 8

Splits the strings into lines and counts the resulted number of lines.

Parameters

array $diff: Array of strings.

File

src/DiffEntityComparison.php, line 232

Class

DiffEntityComparison
Entity comparison service that prepares a diff of a pair of entities.

Namespace

Drupal\diff

Code

public function processStateLine(array &$diff) {
  $data = $diff['#data'];
  if (isset($data['#left']) && $data['#left'] != '') {
    if (is_string($data['#left'])) {
      $diff['#data']['#left'] = explode("\n", $data['#left']);
    }
    $diff['#data']['#count_left'] = count($diff['#data']['#left']);
  }
  else {
    $diff['#data']['#count_left'] = 0;
    $diff['#data']['#left'] = [];
  }
  if (isset($data['#right']) && $data['#right'] != '') {
    if (is_string($data['#right'])) {
      $diff['#data']['#right'] = explode("\n", $data['#right']);
    }
    $diff['#data']['#count_right'] = count($diff['#data']['#right']);
  }
  else {
    $diff['#data']['#count_right'] = 0;
    $diff['#data']['#right'] = [];
  }
}