final class RelationChoice
Public API: explicitly declared with @visibility public.

Selects a set of relations for each row using one discriminator column.

Define alternative parentsdoctest
$choice = \SqlFixture\Plan\RelationChoice::on('comments.kind');
    $choice = $choice->when('post', \SqlFixture\Plan\Relation::manyToOne('comments.target_id', 'posts.id'));
    $choice = $choice->when('none');
    count($choice->cases) // => 2

Properties§

public ColumnRef $discriminator
public list<ChoiceCase> $cases = []
public ?ChoiceCase $fallback = null

Methods§

public function __construct(
    public ColumnRef $discriminator,
    public list<ChoiceCase> $cases = [],
    public ?ChoiceCase $fallback = null,
)

Parameters

$discriminatorColumnRef
$caseslist<ChoiceCase>
$fallback?ChoiceCase
Calls 2
public static function on(string|ColumnRef $discriminator): self

Starts an immutable choice for a table column.

Parameters

$discriminatorstring|ColumnRef

Returns

self
Test cases 37
Called from 1
Calls 2
public function when(string|int|bool|null $value, Relation ...$relations): self

Adds a case; an empty relation list explicitly means no relationship.

Parameters

$valuestring|int|bool|null
$relationsRelation

Returns

self
Calls 4
public function otherwise(Relation ...$relations): self

Handles explicitly supplied values not named by a case.

Parameters

$relationsRelation

Returns

self
Calls 4

Test cases 47§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 7
Other tests reaching this symbol 40

Relations§

Static calls 1
Method calls 5
Type checks 2
Type declarations 12