Commit 5d300851 authored by Guilherme Blanco's avatar Guilherme Blanco

Moved back methods

parent 4f2e7511
......@@ -731,6 +731,36 @@ class Table extends AbstractAsset
return array_merge($primaryKeyColumns, $foreignKeyColumns, $remainderColumns);
}
/**
* Returns the foreign key columns
*
* @return Column[]
*/
public function getForeignKeyColumns()
{
$foreignKeyColumns = [];
foreach ($this->getForeignKeys() as $foreignKey) {
$foreignKeyColumns = array_merge($foreignKeyColumns, $foreignKey->getLocalColumns());
}
return $this->filterColumns($foreignKeyColumns);
}
/**
* Returns only columns that have specified names
*
* @param string[] $columnNames
*
* @return Column[]
*/
private function filterColumns(array $columnNames, bool $reverse = false) : array
{
return array_filter($this->_columns, static function ($columnName) use ($columnNames, $reverse) : bool {
return in_array($columnName, $columnNames, true) !== $reverse;
}, ARRAY_FILTER_USE_KEY);
}
/**
* Returns whether this table has a Column with the given name.
*
......@@ -795,22 +825,6 @@ class Table extends AbstractAsset
return $this->filterColumns($primaryKey->getColumns());
}
/**
* Returns the foreign key columns
*
* @return Column[]
*/
public function getForeignKeyColumns()
{
$foreignKeyColumns = [];
foreach ($this->getForeignKeys() as $foreignKey) {
$foreignKeyColumns = array_merge($foreignKeyColumns, $foreignKey->getLocalColumns());
}
return $this->filterColumns($foreignKeyColumns);
}
/**
* Returns whether this table has a primary key.
*
......@@ -1003,18 +1017,4 @@ class Table extends AbstractAsset
return $this->trimQuotes(strtolower($identifier));
}
/**
* Returns only columns that have specified names
*
* @param string[] $columnNames
*
* @return Column[]
*/
private function filterColumns(array $columnNames, bool $reverse = false) : array
{
return array_filter($this->_columns, static function ($columnName) use ($columnNames, $reverse) : bool {
return in_array($columnName, $columnNames, true) !== $reverse;
}, ARRAY_FILTER_USE_KEY);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment