/** * Change a table column type. * * @param string $columnName Column Name * @param string|Column $newColumnType New Column Type * @param array $options Options * @return Table */ public function changeColumn($columnName, $newColumnType, $options = array()) { // create a column object if one wasn't supplied if (!$newColumnType instanceof Column) { $newColumn = new Column(); $newColumn->setType($newColumnType); $newColumn->setOptions($options); } else { $newColumn = $newColumnType; } // if the name was omitted use the existing column name if (null === $newColumn->getName() || strlen($newColumn->getName()) === 0) { $newColumn->setName($columnName); } $this->getAdapter()->changeColumn($this->getName(), $columnName, $newColumn); return $this; }
/** * @expectedException \RuntimeException * @expectedExceptionMessage "0" is not a valid column option. */ public function testSetOptionThrowsExceptionIfOptionIsNotString() { $column = new Column(); $column->setOptions(['identity']); }
/** * Utility method that maps an array of column options to this objects methods. * * @param array $options Options * * @return $this */ public function setOptions(array $options) { $this->column->setOptions($options); return $this; }