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 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 178
Called from 7
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 139
Called from 12
Calls 1
public function state(string $tableName): ShadowTableState

Return the typed presence state for a shadow table.

Parameters

$tableNamestring
Test cases 2
Calls 4
public function getAll(): array<string, array<int, Row>>
public function clear(): void

Remove all shadow data.

Test cases 1
public function snapshot(): self

Snapshot.

Returns

self
Test cases 35
Called from 2
public function remove(string $tableName): void

Remove both rows and explicit table context from the store.

Parameters

$tableNamestring
Test cases 1
Called from 1
public function insert(string $tableName, array<int, Row> $rows): void
public function delete(
    string $tableName,
    array<int, Row> $deletedRows,
    array<int, string> $primaryKeys = [],
): void
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 242§

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 223

Relations§

Method calls 32
Type declarations 31