Example #1
0
 /**
  * Compares lines
  *
  * @param Table $table
  * @param string $prefix
  *
  * @return string[]
  * @throws \Exception
  */
 private function equalsLines(Table $table, $prefix)
 {
     $thisLines = $this->getLines();
     $tableLines = $table->getLines();
     $errors = [];
     foreach ($thisLines as $line) {
         if (array_key_exists($line->getName(), $tableLines)) {
             $errors = array_merge($errors, $line->equals($tableLines[$line->getName()], $prefix));
         }
     }
     $thisLineNames = array_keys($thisLines);
     $tableLineNames = array_keys($tableLines);
     $diff = array_diff($tableLineNames, $thisLineNames);
     if (!empty($diff)) {
         $errors[] = $prefix . 'Extra Columns: ' . "\n" . implode("\n", $diff);
     }
     $diff = array_diff($thisLineNames, $tableLineNames);
     if (!empty($diff)) {
         $errors[] = $prefix . 'Missing Columns: ' . "\n" . implode("\n", $diff);
     }
     return $errors;
 }