final class ForeignKeyViolationException
    extends SimulationException

Exception thrown when a FOREIGN KEY constraint is violated.

Methods§

public static function of(
    string $sql,
    string $tableName,
    string $constraintName,
    string $referencedTable,
    list<string> $referencedColumns,
): self

Reports a constraint a statement left broken, or was forbidden by.

A key may point at several columns; the message names the first, which is what a database says too.

Parameters

$sqlstringStatement being simulated
$tableNamestringTable holding the key
$constraintNamestringConstraint that was not honoured
$referencedTablestringTable the key points at
$referencedColumnslist<string>Columns it points at

Returns

self Exception naming the constraint and what it points at
Test cases 2
Called from 2
Calls 1
public function __construct(
    string $sql,
    string $tableName,
    string $constraintName,
    string $referencedTable,
    string $referencedColumn,
)
public function getSql(): string

Get the SQL statement.

Returns

string
Test cases 1
public function getTableName(): string
public function getConstraintName(): string

Get the name of the foreign key constraint.

Returns

string
Test cases 1
public function getReferencedTable(): string

Get the name of the referenced table.

Returns

string
Test cases 1

Private surface 5§

Implementation details, listed for orientation only.

private string $sql
private string $tableName
private string $constraintName
private string $referencedTable
private string $referencedColumn

Test cases 15§

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

Dedicated tests 8
Other tests reaching this symbol 7

Relations§

Static calls 2