Skip to content

Commit

Permalink
Refactor column schema (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Mar 21, 2023
1 parent 35dac6d commit 2481289
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,25 +398,26 @@ protected function getTableSequenceName(string $tableName): bool|float|int|strin

/**
* Creates ColumnSchema instance.
*
* @param array|string $column
*
* @psalm-param array{
* column_name: string,
* data_type: string,
* data_precision: string,
* data_scale: string,
* data_length: string,
* nullable: string,
* data_default: string|null,
* is_pk: string|null,
* column_comment: string|null
* } $column
*
* @return ColumnSchemaInterface
*/
protected function createColumnSchema(array|string $column): ColumnSchemaInterface
{
$c = new ColumnSchema();

/**
* @psalm-var array{
* column_name: string,
* data_type: string,
* data_precision: string,
* data_scale: string,
* data_length: string,
* nullable: string,
* data_default: string|null,
* is_pk: string|null,
* column_comment: string|null
* } $column
*/
$c->name($column['column_name']);
$c = new ColumnSchema($column['column_name']);
$c->allowNull($column['nullable'] === 'Y');
$c->comment($column['column_comment'] ?? '');
$c->primaryKey((int) ($column['is_pk'] ?? 0) > 0);
Expand Down

0 comments on commit 2481289

Please sign in to comment.