Class CheckConstraint
Check constraint value object
Models a check constraint.
Constants
Property Summary
-
$type protected
string
Method Summary
-
__construct() public
Constructor
-
getColumns() public
Gets the constraint columns.
-
getExpression() public
Get the check constraint expression.
-
getName() public
Gets the constraint name.
-
getType() public
Gets the constraint type.
-
setColumns() public
Sets the constraint columns.
-
setExpression() public
Set the check constraint expression.
-
setName() public
Sets the constraint name.
-
setType() public
Sets the constraint type.
-
toArray() public
Converts a constraint to an array that is compatible with the constructor.
Method Detail
__construct() ¶ public
__construct(string $name, string $expression)
Constructor
Parameters
-
string$name Constraint name.
-
string$expression The check constraint expression (e.g., "age >= 18")
getColumns() ¶ public
getColumns(): ?array<string>
Gets the constraint columns.
Returns
?array<string>getExpression() ¶ public
getExpression(): string
Get the check constraint expression.
Returns
stringsetColumns() ¶ public
setColumns(array<string>|string $columns): $this
Sets the constraint columns.
Parameters
-
array<string>|string$columns Columns
Returns
$thissetExpression() ¶ public
setExpression(string $expression): $this
Set the check constraint expression.
Parameters
-
string$expression The SQL expression for the check constraint
Returns
$thisThrows
InvalidArgumentExceptionsetName() ¶ public
setName(string $name): $this
Sets the constraint name.
Parameters
-
string$name Name
Returns
$thissetType() ¶ public
setType(string $type): $this
Sets the constraint type.
Parameters
-
string$type Type
Returns
$thistoArray() ¶ public
toArray(): array<string, mixed>
Converts a constraint to an array that is compatible with the constructor.
Returns
array<string, mixed>