WP-Query-Builder/interfaces/TableBlueprint.php
2025-02-03 17:44:52 +01:00

60 lines
2.0 KiB
PHP

<?php
namespace DatabaseHelper\interfaces;
use DatabaseHelper\enums\ColumnTypes;
use DatabaseHelper\enums\CascadeTypes;
use DatabaseHelper\enums\EngineTypes;
use DatabaseHelper\enums\CharsetTypes;
use DatabaseHelper\enums\CollationTypes;
/**
* Defines a blueprint for building database tables with a fluent interface, which supports method chaining.
*/
interface TableBlueprint
{
public function __construct(string $tableName);
/**
* Adds a column.
* @param string $colName Column name.
* @param ColumnTypes $colType Column type.
* @param mixed|null $default Default value (optional).
* @param bool $nullable Nullable column (default: false).
* @param bool $unique Unique constraint (default: false).
* @return TableBlueprint Current instance for method chaining.
*/
public function column(string $colName, ColumnTypes $colType, mixed $default = null, bool $nullable = false, bool $unique = false): TableBlueprint;
public function primary(string $colName, ColumnTypes $colType, bool $autoInc = false): TableBlueprint;
public function referenceColumn(TableBlueprint $foreignTable, CascadeTypes $onDelete, CascadeTypes $onUpdate): TableBlueprint;
/**
* Sets the table engine.
* @param EngineTypes $engine Storage engine.
* @return TableBlueprint Current instance for method chaining.
*/
public function engine(EngineTypes $engine): TableBlueprint;
/**
* Sets the character set.
* @param CharsetTypes $charset Character set.
* @return TableBlueprint Current instance for method chaining.
*/
public function charset(CharsetTypes $charset): TableBlueprint;
/**
* Sets the collation.
* @param CollationTypes $collation Collation to use.
* @return TableBlueprint Current instance for method chaining.
*/
public function collation(CollationTypes $collation): TableBlueprint;
/**
* Creates the blueprinted table.
* @return TableBlueprint
*/
public function create(): TableBlueprint;
}