Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Split columnType() into getter/setter.
  • Loading branch information
Robert Pustułka committed May 24, 2017
1 parent e23f836 commit e9e5094
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/Database/Schema/TableSchema.php
Expand Up @@ -512,20 +512,51 @@ public function column($name)
* @param string $name The column to get the type of.
* @param string|null $type The type to set the column to.
* @return string|null Either the column type or null.
* @deprecated 3.5.0 Use setColumnType()/getColumnType() instead.
*/
public function columnType($name, $type = null)
{
if ($type !== null) {
$this->setColumnType($name, $type);
}

return $this->getColumnType($name);
}

/**
* Returns column type or null if a column does not exist.
*
* @param string $name The column to get the type of.
* @return string|null
*/
public function getColumnType($name)
{
if (!isset($this->_columns[$name])) {
return null;
}
if ($type !== null) {
$this->_columns[$name]['type'] = $type;
$this->_typeMap[$name] = $type;
}

return $this->_columns[$name]['type'];
}

/**
* Sets the type of a column.
*
* @param string $name The column to set the type of.
* @param string $type The type to set the column to.
* @return $this
*/
public function setColumnType($name, $type)
{
if (!isset($this->_columns[$name])) {
return $this;
}

$this->_columns[$name]['type'] = $type;
$this->_typeMap[$name] = $type;

return $this;
}

/**
* Returns the base type name for the provided column.
* This represent the database type a more complex class is
Expand Down

0 comments on commit e9e5094

Please sign in to comment.