Lines
100.00%
1 / 1
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Check | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace BlueprintAU\Radiant\Attributes; | |
| 6 | ||
| 7 | /** | |
| 8 | * Declares a table-level CHECK constraint (class-level). | |
| 9 | * | |
| 10 | * CHECK is portable across all supported dialects (MySQL, Postgres, | |
| 11 | * SQLite). The expression is spliced verbatim — the raw escape hatch, | |
| 12 | * same trust model as an Expression column default. Column names inside | |
| 13 | * the expression are NOT validated (the expression may legitimately mix | |
| 14 | * columns with dialect functions); a typo surfaces as a DDL error at | |
| 15 | * apply time. | |
| 16 | * | |
| 17 | * An explicitly named constraint keeps the given name verbatim; unnamed | |
| 18 | * constraints render the derived `{table}_{columns}_check` name. MySQL | |
| 19 | * 8.0.16+ enforces CHECK constraints; older MySQL parses-and-ignores | |
| 20 | * them. | |
| 21 | */ | |
| 22 | #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)] | |
| 23 | final class Check | |
| 24 | { | |
| 25 | /** | |
| 26 | * Create a CHECK constraint declaration. | |
| 27 | * | |
| 28 | * @param string $expression | |
| 29 | * @param string|null $name | |
| 30 | */ | |
| 31 | public function __construct( | |
| 32 | public string $expression, | |
| 33 | public ?string $name = null, | |
| 34 | ) { | |
| 35 | } | |
| 36 | } |