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 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Table | 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 | * Overrides table-level metadata for a model. | |
| 9 | * | |
| 10 | * Fully optional: a model without it gets the snake-cased plural of its | |
| 11 | * short class name (see {@see \BlueprintAU\Radiant\Metadata\MetadataFactory::defaultTableName()}), and | |
| 12 | * `name` itself is optional so the attribute can carry ONLY other | |
| 13 | * table-level settings without duplicating the default name — duplicating | |
| 14 | * it would silently drift when the class is renamed. When `name` is null | |
| 15 | * the convention applies; when it is set it must be non-empty (an empty | |
| 16 | * string is a mis-declaration and fails fast at metadata build). | |
| 17 | * | |
| 18 | * **Dynamic table names: deliberately unsupported.** A model-level hook | |
| 19 | * (e.g. a static `resolveTableName()`) would need per-request state (tenant | |
| 20 | * id, date bucket) to reach a static method through globals — the | |
| 21 | * service-locator pattern this package forbids — and caching the result | |
| 22 | * would cross tenants. Static names only, via `name` or the convention. | |
| 23 | * Real sharding is a CONNECTION-layer concern: point a tenant at its own | |
| 24 | * entry in the DatabaseManager map (explicit wiring, no hidden state). | |
| 25 | * | |
| 26 | * **What else `#[Table]` should own (when those features land):** `schema` | |
| 27 | * (the database/schema qualifier for cross-database joins), `comment` (a | |
| 28 | * table COMMENT in the DDL), and `charset`/`collation` (MySQL table-level | |
| 29 | * defaults — only if a real model needs a per-table override). | |
| 30 | * | |
| 31 | * Composite constraints (unique / foreign key / index) do NOT live here — | |
| 32 | * they are separate class-level attributes ({@see Unique}, | |
| 33 | * {@see ForeignKey}, {@see Index}). `#[Table]` stays a | |
| 34 | * naming/placement concern; constraints are a vocabulary of their own. | |
| 35 | */ | |
| 36 | #[\Attribute(\Attribute::TARGET_CLASS)] | |
| 37 | final class Table | |
| 38 | { | |
| 39 | /** | |
| 40 | * Create a table override. | |
| 41 | * | |
| 42 | * @param string|null $name | |
| 43 | */ | |
| 44 | public function __construct( | |
| 45 | public string|null $name = null, | |
| 46 | ) {} | |
| 47 | } |