PrecomputedPresenceVerifier
final class PrecomputedPresenceVerifier implements DatabasePresenceVerifierInterface
Presence verifier that returns pre-computed results from batched queries.
Used by BatchDatabaseChecker to replace per-item DB queries with lookup-set checks. Original Exists/Unique rule objects stay in place, so the full message resolution pipeline works unchanged.
Results are scoped by table+column. Falls back to the provided verifier for lookups that weren't pre-computed (rules with closure callbacks).
Methods
Register pre-computed values for a table+column pair.
Count the number of objects in a collection having the given value.
Count the number of objects in a collection with the given values.
Set the connection to be used.
Determine if any lookups have been registered.
Details
at line 22
__construct(PresenceVerifierInterface|null $fallback = null)
No description
at line 35
void
addLookup(string $table, string $column, array $values)
Register pre-computed values for a table+column pair.
Values are cast to strings and stored as a flip map for O(1) isset() lookups. String cast matches database implicit type coercion behavior.
at line 57
int
getCount(string $collection, string $column, string $value, int|string|null $excludeId = null, string|null $idColumn = null, array $extra = [])
Count the number of objects in a collection having the given value.
Returns 1 if the value exists in the precomputed lookup, 0 otherwise. Falls back to the original verifier when no lookup was registered for this table:column pair.
at line 78
int
getMultiCount(string $collection, string $column, array $values, array $extra = [])
Count the number of objects in a collection with the given values.
Uses distinct counting to match DatabasePresenceVerifier's ->distinct()->count($column) semantics. Duplicate input values are counted only once.
at line 111
void
setConnection(string|null $connection)
Set the connection to be used.
Delegates to the fallback verifier if it supports connections.
at line 121
bool
hasLookups()
Determine if any lookups have been registered.