| Total Complexity | 3 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | abstract class Table extends TableAccess implements Middleware |
||
| 15 | { |
||
| 16 | use TableMiddlewareTrait; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Table constructor. |
||
| 20 | * @param string $tableName |
||
| 21 | */ |
||
| 22 | public function __construct(string $tableName) |
||
| 23 | { |
||
| 24 | parent::__construct($this->initStruct($tableName), Database::application()->getDataSource(), $this); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * 构建数据表 |
||
| 29 | * @param TableStruct $table |
||
| 30 | * @return TableStruct |
||
| 31 | */ |
||
| 32 | abstract public function onCreateStruct(TableStruct $table):TableStruct; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * 创建表结构 |
||
| 36 | * |
||
| 37 | * @param string $tableName |
||
| 38 | * @return TableStruct |
||
| 39 | */ |
||
| 40 | protected function initStruct(string $tableName):TableStruct |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * 结构继承 |
||
| 48 | * @param Table $table |
||
| 49 | * @return bool |
||
| 50 | */ |
||
| 51 | public function isSubOf(Table $table) |
||
| 56 |