$columns The columns to constraint. * @param string $type The type of constraint, e.g. 'unique', 'primary'. */ public function __construct( protected string $name, protected array $columns, protected string $type, ) { } /** * Sets the constraint columns. * * @param array|string $columns Columns * @return $this */ public function setColumns(string|array $columns) { $this->columns = (array)$columns; return $this; } /** * Gets the constraint columns. * * @return ?array */ public function getColumns(): ?array { return $this->columns; } /** * Sets the constraint type. * * @param string $type Type * @return $this */ public function setType(string $type) { $this->type = $type; return $this; } /** * Gets the constraint type. * * @return string */ public function getType(): string { return $this->type; } /** * Sets the constraint name. * * @param string $name Name * @return $this */ public function setName(string $name) { $this->name = $name; return $this; } /** * Gets the constraint name. * * @return ?string */ public function getName(): ?string { return $this->name; } /** * Converts a constraint to an array that is compatible * with the constructor. * * @return array */ public function toArray(): array { return [ 'name' => $this->name, 'type' => $this->type, 'columns' => $this->columns, ]; } }