class ShadowStore
Public API: explicitly declared with @visibility public.

Holds in-memory shadow rows for tables.

Type Aliases§

Row = import from TableDefinition
Snapshot and restore fixture rowsdoctest
$store = new \ZtdQuery\Shadow\ShadowStore();
    $store->set('users', [['id' => 1, 'name' => 'Alice']]);
    $snapshot = $store->snapshot();
    $store->update('users', [['id' => 1, 'name' => 'Bob']], ['id']);
    $store->get('users') // => [['id' => 1, 'name' => 'Bob']]
    $store->restore($snapshot);
    $store->get('users') // => [['id' => 1, 'name' => 'Alice']]

Methods§

public function __construct(private RowMatch $match = new \ZtdQuery\Shadow\Row\RowMatch())

Parameters

$matchRowMatchDecides when a stored row is the row a caller means
Calls 1
public function set(string $tableName, array<int, Row> $rows): void

Replaces every shadow row of a table.

The caller's row keys and values are retained unchanged.

Parameters

$tableNamestring
$rowsarray<int, Row>Rows the table now has, in order
Test cases 382
Called from 12
Calls 1
public function get(string $tableName): array<int, Row>

Get all shadow rows for a table.

Parameters

$tableNamestring

Returns

array<int, Row>
Test cases 248
Called from 19
Calls 1
public function state(string $tableName): ShadowTableState

Return the typed presence state for a shadow table.

Parameters

$tableNamestring
Test cases 11
Called from 8
Calls 4
public function getAll(): array<string, array<int, Row>>

Get all stored shadow tables.

Returns

array<string, array<int, Row>>
Test cases 17
Called from 7
public function clear(): void
public function snapshot(): self

Snapshot.

Returns

self
Test cases 37
Called from 2
public function ensure(string $tableName): void

Ensure a table key exists in the store.

Parameters

$tableNamestring
Test cases 59
Called from 9
Calls 2
public function insert(string $tableName, array<int, Row> $rows): void

Append rows to a table shadow set.

Parameters

$tableNamestring
$rowsarray<int, Row>
Test cases 35
Called from 2
Calls 3
public function update(
    string $tableName,
    array<int, Row> $updatedRows,
    array<int, string> $primaryKeys,
): void

Update rows matched by primary keys.

Parameters

$tableNamestring
$updatedRowsarray<int, Row>
$primaryKeysarray<int, string>

Throws

MissingPrimaryKeyException When the table declares no key to identify a row by
Test cases 5
Calls 3
public function updateIdentified(
    string $tableName,
    list<array{row: Row, identity: Row}> $updates,
    array<int, string> $primaryKeys,
): void

Private surface 3§

Implementation details, listed for orientation only.

private RowMatch $match = new \ZtdQuery\Shadow\Row\RowMatch()
private array<string, RowSet> $fixtures = []
private array<string, string> $initializedTables = []

Test cases 1354§

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

Dedicated tests 19
Other tests reaching this symbol 1335

Relations§

Instantiated in 3
Method calls 69
Type declarations 65