class DbUsernameRecoveryRepository (View source)

Methods

__construct(PDO $db, ConfigurationManager $config)

No description

bool
create(array $data)

Create a new username recovery request record

int
countRecentAttempts(string $email, int $seconds)

Count recent recovery attempts for a specific email address

int
countRecentAttemptsByIp(string $ip, int $seconds)

Count recent recovery attempts by IP address

string|null
getLastAttemptTime(string $email)

Get the timestamp of the last recovery attempt for an email

int
deleteOlderThan(int $days = 30)

Delete old recovery request records

int
deleteByEmail(string $email)

Delete all recovery requests for a specific email

int
getTotalCount()

Get total count of recovery requests in the system

Details

__construct(PDO $db, ConfigurationManager $config)

No description

Parameters

PDO $db
ConfigurationManager $config

bool create(array $data)

Create a new username recovery request record

Parameters

array $data

Request data containing email and ip_address

Return Value

bool

True if the record was created successfully

int countRecentAttempts(string $email, int $seconds)

Count recent recovery attempts for a specific email address

Parameters

string $email

Email address to check

int $seconds

Time window in seconds to check within

Return Value

int

Number of attempts in the time window

int countRecentAttemptsByIp(string $ip, int $seconds)

Count recent recovery attempts by IP address

Parameters

string $ip

IP address to check

int $seconds

Time window in seconds to check within

Return Value

int

Number of attempts from this IP in the time window

string|null getLastAttemptTime(string $email)

Get the timestamp of the last recovery attempt for an email

Parameters

string $email

Email address to check

Return Value

string|null

Timestamp of last attempt, or null if no attempts found

int deleteOlderThan(int $days = 30)

Delete old recovery request records

Cleanup strategy:

  • Delete records older than the specified number of days
  • Default: 30 days for audit trail purposes

This method can be called periodically for maintenance.

Parameters

int $days

Number of days to keep records (default: 30)

Return Value

int

Number of deleted records

int deleteByEmail(string $email)

Delete all recovery requests for a specific email

Parameters

string $email

Email address

Return Value

int

Number of deleted records

int getTotalCount()

Get total count of recovery requests in the system

Return Value

int

Total number of records