DatabaseEmailVerificationTokenRepository
in package
implements
IEmailVerificationTokenRepository
Database-backed email verification token repository.
Works with SQLite, MySQL, and PostgreSQL via PDO.
Table of Contents
Interfaces
- IEmailVerificationTokenRepository
- Email verification token repository interface.
Properties
- $_pdo : PDO
Methods
- __construct() : mixed
- Constructor
- __sleep() : array<string|int, mixed>
- Handle serialization for PHPUnit process isolation
- __wakeup() : void
- Handle unserialization for PHPUnit process isolation
- create() : EmailVerificationToken
- Create a new email verification token
- deleteByToken() : bool
- Delete a specific token by its hashed value
- deleteByUserId() : int
- Delete all tokens for a given user ID
- deleteExpired() : int
- Delete all expired tokens
- findByToken() : EmailVerificationToken|null
- Find a token by its hashed value
- findByUserId() : EmailVerificationToken|null
- Find most recent token by user ID
- mapRowToToken() : EmailVerificationToken
- Map database row to EmailVerificationToken object
Properties
$_pdo
private
PDO
$_pdo
Methods
__construct()
Constructor
public
__construct(SettingManager $settings) : mixed
Parameters
- $settings : SettingManager
-
Settings manager with database configuration
Tags
__sleep()
Handle serialization for PHPUnit process isolation
public
__sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>__wakeup()
Handle unserialization for PHPUnit process isolation
public
__wakeup() : void
create()
Create a new email verification token
public
create(EmailVerificationToken $token) : EmailVerificationToken
Parameters
- $token : EmailVerificationToken
-
Token to create
Return values
EmailVerificationToken —Created token with ID set
deleteByToken()
Delete a specific token by its hashed value
public
deleteByToken(string $token) : bool
Parameters
- $token : string
-
Hashed token
Return values
bool —True if deleted, false otherwise
deleteByUserId()
Delete all tokens for a given user ID
public
deleteByUserId(int $userId) : int
Parameters
- $userId : int
-
User ID
Return values
int —Number of tokens deleted
deleteExpired()
Delete all expired tokens
public
deleteExpired() : int
Return values
int —Number of tokens deleted
findByToken()
Find a token by its hashed value
public
findByToken(string $token) : EmailVerificationToken|null
Parameters
- $token : string
-
Hashed token
Return values
EmailVerificationToken|null —Token if found, null otherwise
findByUserId()
Find most recent token by user ID
public
findByUserId(int $userId) : EmailVerificationToken|null
Parameters
- $userId : int
-
User ID
Return values
EmailVerificationToken|null —Most recent token if found, null otherwise
mapRowToToken()
Map database row to EmailVerificationToken object
private
mapRowToToken(array<string|int, mixed> $row) : EmailVerificationToken
Parameters
- $row : array<string|int, mixed>