final class DuplicateKeyException<TValue>
    extends SimulationException

Exception thrown when a PRIMARY KEY or UNIQUE constraint is violated.

A refusal says what it is about without naming the schema it came from, so the key values it carries are spelled out here rather than imported.

Type Aliases§

KeyValues = array<string, TValue>

Methods§

public function __construct(
    string $sql,
    string $tableName,
    string $keyName,
    KeyValues $keyValues = [],
)

Parameters

$sqlstringThe SQL statement.
$tableNamestringThe name of the table.
$keyNamestringThe name of the key constraint.
$keyValuesKeyValuesThe duplicate key values.
Calls 4
public function getSql(): string

Get the SQL statement.

Returns

string
Test cases 1
public function getTableName(): string

Get the name of the table.

Returns

string
Test cases 1
public function getKeyName(): string

Get the name of the key constraint.

Returns

string
Test cases 1
public function getKeyValues(): KeyValues

Get the duplicate key values.

Returns

Test cases 1
public static function formatKeyValue(mixed $value): string

Formats a duplicate value without coercing the value stored in the exception.

Parameters

$valuemixed

Returns

string
Test cases 1
Called from 1
Calls 4

Private surface 4§

Implementation details, listed for orientation only.

private string $sql
private string $tableName
private string $keyName
private KeyValues $keyValues

Test cases 17§

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

Dedicated tests 10
Other tests reaching this symbol 7

Relations§

Instantiated in 3