class FixturePlan
    implements Stringable
Public API: explicitly declared with @visibility public.

The parsed form of a fixture plan: which tables take part, and how their columns line up.

This type is the plan. The DBML relation string is one way to write it down and from() reads it; toString() writes it back. Building it up method by method, or declaring one as a class, produce the same value by other routes:

FixturePlan::from('order.id < order_detail.order_id');

(new FixturePlan())->withOneToMany('order.id', 'order_detail.order_id');

final class OrderWithDetails extends FixturePlan { public function __construct() { parent::__construct( Relation::oneToMany('order.id', 'order_detail.order_id'), Relation::manyToOne('order.customer_id', 'customer.id'), ); } }

A subclass names a plan without adding a kind of plan, so the builders below return a plain FixturePlan rather than the subclass: once a declared plan is altered it is no longer the plan that class stands for.

Build and print a relational fixture plandoctest
$plan = \SqlFixture\Plan\FixturePlan::from('users.id < posts.user_id');
    $plan->tables // => ['users', 'posts']
    $plan->toString() // => 'users.id < posts.user_id'

Properties§

public list<Relation> $relations
public list<string> $tables
public list<string> $generationOrder

Methods§

public static function from(string|self $plan): self

Read a plan written in the DBML relation syntax.

Parameters

$planstring|self

Returns

self
Test cases 66
Called from 1
Calls 3
public function withOneToMany(
    string|ColumnRef $parent,
    string|ColumnRef $child,
    bool $childOptional = false,
): self

Add parent.column < child.column.

Parameters

$parentstring|ColumnRef
$childstring|ColumnRef
$childOptionalbool

Returns

self
Calls 2
public function withManyToOne(
    string|ColumnRef $child,
    string|ColumnRef $parent,
    bool $parentOptional = false,
): self

Add child.column > parent.column.

Parameters

$childstring|ColumnRef
$parentstring|ColumnRef
$parentOptionalbool

Returns

self
Calls 2
public function withOneToOne(
    string|ColumnRef $parent,
    string|ColumnRef $child,
    bool $childOptional = false,
): self

Add parent.column - child.column.

Parameters

$parentstring|ColumnRef
$childstring|ColumnRef
$childOptionalbool

Returns

self
Calls 2
public function withTable(string $table): self

Name a table that takes part without being related to anything.

Parameters

$tablestring

Returns

self
Test cases 1
Calls 1
public function subjectTable(): ?string

The table the fixtures are about, which is the first one named.

This is where the plan reads from, not where generation starts: written order_detail.order_id > order.id the subject is order_detail, but order has to exist first. Use generationOrder for that.

Returns

?string
Test cases 1
public function roots(): list<string>

Tables nothing else has to be generated before.

Returns

list<string>
Calls 1
public function dependenciesOf(string $table): list<Relation>

Relations that must be satisfied before this table can be generated, that is, those in which it is the child.

Parameters

$tablestring

Returns

list<Relation>
Called from 2
Calls 3
public function dependentsOf(string $table): list<Relation>

Relations hanging off this table, that is, those in which it is the parent.

Parameters

$tablestring

Returns

list<Relation>
Called from 2
Calls 3
public function __toString(): string

Returns the canonical textual representation.

Returns

string
Calls 1

Private surface 1§

Implementation details, listed for orientation only.

private list<Relation|string> $parts

Test cases 110§

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

Dedicated tests 36
Other tests reaching this symbol 74

Relations§

Instantiated in 1
Static calls 1
Method calls 3
Type declarations 14