Fleshing out Migrator/DB Model stuff
This commit is contained in:
parent
e4e8609acc
commit
1d15fc8493
3 changed files with 78 additions and 0 deletions
9
src/Entities/Column.php
Normal file
9
src/Entities/Column.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace ⌬\Database\Entities;
|
||||
|
||||
class Column extends Entity
|
||||
{
|
||||
protected $columnName;
|
||||
|
||||
}
|
||||
32
src/Entities/Entity.php
Normal file
32
src/Entities/Entity.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace ⌬\Database\Entities;
|
||||
|
||||
use ⌬\Migrator\Traits\MySQLSupport;
|
||||
use ⌬\Migrator\Traits\Support;
|
||||
|
||||
abstract class Entity
|
||||
{
|
||||
/** @var Support */
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @return Support
|
||||
*/
|
||||
public function getContainer(): Support
|
||||
{
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Support $container
|
||||
* @return Entity
|
||||
*/
|
||||
public function setContainer(Support $container): Entity
|
||||
{
|
||||
$this->container = $container;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
37
src/Entities/Table.php
Normal file
37
src/Entities/Table.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace ⌬\Database\Entities;
|
||||
|
||||
class Table extends Entity
|
||||
{
|
||||
/** @var string */
|
||||
protected $tableName;
|
||||
/** @var Column */
|
||||
protected $columns;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTableName()
|
||||
{
|
||||
return $this->tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $tableName
|
||||
* @return Table
|
||||
*/
|
||||
public function setTableName($tableName)
|
||||
{
|
||||
$this->tableName = $tableName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addColumn(string $name, array $options) : self
|
||||
{
|
||||
$this->columns[] = $column = (new Column())
|
||||
->setContainer($this->getContainer())
|
||||
->setOptions($options);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue