Esempio n. 1
0
 /**
  * Compares two lines, and returns any errors of non matches
  *
  * @param Line $line
  * @param string $prefix
  *
  * @return string[]
  * @throws \Exception
  */
 public function equals(Line $line, $prefix)
 {
     $prefix .= ': Column (' . $this->getName() . '):';
     $errors = [];
     if ($line->getName() !== $this->getName()) {
         throw new \Exception('Comparing Incomparable columns');
     }
     if ($line->getType() !== $this->getType()) {
         $errors[] = $prefix . 'Type Does Not Match:' . "\n" . $line->getType() . "\n" . $this->getType();
     }
     if ($line->isUnsigned() !== $this->isUnsigned()) {
         $errors[] = $prefix . 'Unsigned Does Not Match:' . "\n" . $line->isUnsigned() . "\n" . $this->isUnsigned();
     }
     if ($line->isNullable() !== $this->isNullable()) {
         $errors[] = $prefix . 'Nullable Does Not Match:' . "\n" . $line->isNullable() . "\n" . $this->isNullable();
     }
     if ($line->isAutoIncrement() !== $this->isAutoIncrement()) {
         $errors[] = $prefix . 'AutoIncrement Does Not Match:' . "\n" . $line->isAutoIncrement() . "\n" . $this->isAutoIncrement();
     }
     if ($line->getCollate() !== $this->getCollate()) {
         $errors[] = $prefix . 'Collate Does Not Match:' . "\n" . $line->getCollate() . "\n" . $this->getCollate();
     }
     if ($line->getComment() !== $this->getComment()) {
         $errors[] = $prefix . 'Comment Does Not Match:' . "\n" . $line->getComment() . "\n" . $this->getComment();
     }
     if ($line->getDefault() !== $this->getDefault()) {
         $errors[] = $prefix . 'Default Does Not Match:' . "\n" . $line->getDefault() . "\n" . $this->getDefault();
     }
     return $errors;
 }