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

Classifies SQL and enforces ZTD write-protection rules for SQLite.

Identify simulated writesdoctest
$guard = new \ZtdQuery\Platform\Sqlite\Rewrite\SqliteQueryGuard(new \ZtdQuery\Platform\Sqlite\Sql\SqliteParser());
    $guard->classify("DELETE FROM users") // => \ZtdQuery\Rewrite\QueryKind::WRITE_SIMULATED

Methods§

public function __construct(SqliteParser $parser)
Public API: explicitly declared with @visibility public.

Binds the dependencies used by this operation.

Parameters

Use the SQLite parser for classificationdoctest
$guard = new \ZtdQuery\Platform\Sqlite\Rewrite\SqliteQueryGuard(new \ZtdQuery\Platform\Sqlite\Sql\SqliteParser());
    $guard->classify("SELECT 1") // => \ZtdQuery\Rewrite\QueryKind::READ
public function classify(string $sql): ?QueryKind
Public API: explicitly declared with @visibility public.

Classify a SQL string into READ/WRITE_SIMULATED/DDL_SIMULATED or null if unsupported.

Parameters

$sqlstring

Returns

Distinguish reads, virtual DDL and unsupported operationsdoctest
$guard = new \ZtdQuery\Platform\Sqlite\Rewrite\SqliteQueryGuard(new \ZtdQuery\Platform\Sqlite\Sql\SqliteParser());
    $guard->classify("CREATE TABLE users(id INTEGER)") // => \ZtdQuery\Rewrite\QueryKind::DDL_SIMULATED
    $guard->classify("VACUUM") // => null
Test cases 23
Called from 2
Calls 6
public function assertAllowed(string $sql): void
Public API: explicitly declared with @visibility public.

Assert that the SQL is allowed by the guard.

Parameters

$sqlstring

Throws

RuntimeException When the SQL is not allowed.
Reject operations that would modify the physical databasedoctest
$guard = new \ZtdQuery\Platform\Sqlite\Rewrite\SqliteQueryGuard(new \ZtdQuery\Platform\Sqlite\Sql\SqliteParser());
    $guard->assertAllowed('SELECT 1');
    $guard->assertAllowed('VACUUM') // throws \RuntimeException: ZTD Write Protection
Test cases 4
Calls 2

Private surface 1§

Implementation details, listed for orientation only.

private SqliteParser $parser

Test cases 114§

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

Dedicated tests 25
Other tests reaching this symbol 89

Relations§

Instantiated in 1
Method calls 1
Type declarations 3