Skip to content

Commit

Permalink
Add create method to Column class
Browse files Browse the repository at this point in the history
The create method has been added to the Column class in the src/Column.php file. This static factory method simplifies the process of creating new column instances by not requiring the 'new' keyword to instantiate the object. It allows for flexible instantiation with custom parameters for name, column type, and size.
  • Loading branch information
krzysztofzylka committed Dec 24, 2023
1 parent 32a8ad2 commit d7f5079
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ class Column

private array $triggers = [];

/**
* Creates a new instance of the class.
* @param string|null $name The name of the column (optional)
* @param ColumnType $columnType The type of the column (default: ColumnType::varchar)
* @param mixed $size The size of the column (default: 255)
* @return self The new instance of the class
*/
public static function create(?string $name = null, ColumnType $columnType = ColumnType::varchar, mixed $size = 255): self
{
return new self($name, $columnType, $size);
}

/**
* Constructor
* @param ?string $name
Expand Down

0 comments on commit d7f5079

Please sign in to comment.