UserRepositoryInterface
in
Repository interface for User entity.
Defines the contract for user persistence operations. Implementations may use different storage backends (MySQL, memory, etc.)
Tags
Table of Contents
Methods
- activate() : bool
- Activate a user account.
- deactivate() : bool
- Deactivate a user account.
- delete() : bool
- Delete a user by ID.
- emailExists() : bool
- Check if an email exists.
- exists() : bool
- Check if a user exists.
- find() : User|null
- Find a user by ID.
- findActive() : array<string|int, User>
- Find all active users.
- findByApiToken() : User|null
- Find a user by API token.
- findByEmail() : User|null
- Find a user by email.
- findByGoogleId() : User|null
- Find a user by Google ID.
- findByMicrosoftId() : User|null
- Find a user by Microsoft ID.
- findByPasswordResetToken() : User|null
- Find a user by password reset token.
- findByRememberToken() : User|null
- Find a user by remember-me token.
- findByUsername() : User|null
- Find a user by username.
- findByWordPressId() : User|null
- Find a user by WordPress ID.
- getBasicInfo() : array{id: int, username: string, email: string, is_active: bool, is_admin: bool}|null
- Get basic user info (minimal data for lists).
- getForSelect() : array<int, array{id: int, username: string, email: string}>
- Get users formatted for select dropdown options.
- save() : int
- Save a user entity (create or update).
- updateApiToken() : bool
- Update the API token.
- updateLastLogin() : bool
- Update the last login timestamp.
- updatePassword() : bool
- Update the password hash.
- updatePasswordResetToken() : bool
- Update the password reset token.
- updateRememberToken() : bool
- Update the remember-me token.
- usernameExists() : bool
- Check if a username exists.
Methods
activate()
Activate a user account.
public
activate(int $userId) : bool
Parameters
- $userId : int
-
User ID
Return values
bool —True if updated
deactivate()
Deactivate a user account.
public
deactivate(int $userId) : bool
Parameters
- $userId : int
-
User ID
Return values
bool —True if updated
delete()
Delete a user by ID.
public
delete(int $id) : bool
Parameters
- $id : int
-
User ID
Return values
bool —True if deleted
emailExists()
Check if an email exists.
public
emailExists(string $email[, int|null $excludeId = null ]) : bool
Parameters
- $email : string
-
Email to check
- $excludeId : int|null = null
-
User ID to exclude (for updates)
Return values
boolexists()
Check if a user exists.
public
exists(int $id) : bool
Parameters
- $id : int
-
User ID
Return values
boolfind()
Find a user by ID.
public
find(int $id) : User|null
Parameters
- $id : int
-
User ID
Return values
User|nullfindActive()
Find all active users.
public
findActive() : array<string|int, User>
Return values
array<string|int, User>findByApiToken()
Find a user by API token.
public
findByApiToken(string $token) : User|null
Parameters
- $token : string
-
The API token
Return values
User|nullfindByEmail()
Find a user by email.
public
findByEmail(string $email) : User|null
Parameters
- $email : string
-
The email address
Return values
User|nullfindByGoogleId()
Find a user by Google ID.
public
findByGoogleId(string $googleId) : User|null
Parameters
- $googleId : string
-
The Google user ID
Return values
User|nullfindByMicrosoftId()
Find a user by Microsoft ID.
public
findByMicrosoftId(string $microsoftId) : User|null
Parameters
- $microsoftId : string
-
The Microsoft user ID
Return values
User|nullfindByPasswordResetToken()
Find a user by password reset token.
public
findByPasswordResetToken(string $token) : User|null
Parameters
- $token : string
-
The password reset token (hashed)
Return values
User|nullfindByRememberToken()
Find a user by remember-me token.
public
findByRememberToken(string $token) : User|null
Parameters
- $token : string
-
The remember token
Return values
User|nullfindByUsername()
Find a user by username.
public
findByUsername(string $username) : User|null
Parameters
- $username : string
-
The username
Return values
User|nullfindByWordPressId()
Find a user by WordPress ID.
public
findByWordPressId(int $wordPressId) : User|null
Parameters
- $wordPressId : int
-
The WordPress user ID
Return values
User|nullgetBasicInfo()
Get basic user info (minimal data for lists).
public
getBasicInfo(int $userId) : array{id: int, username: string, email: string, is_active: bool, is_admin: bool}|null
Parameters
- $userId : int
-
User ID
Return values
array{id: int, username: string, email: string, is_active: bool, is_admin: bool}|nullgetForSelect()
Get users formatted for select dropdown options.
public
getForSelect([int $maxNameLength = 40 ]) : array<int, array{id: int, username: string, email: string}>
Parameters
- $maxNameLength : int = 40
-
Maximum username length before truncation
Return values
array<int, array{id: int, username: string, email: string}>save()
Save a user entity (create or update).
public
save(User $entity) : int
Parameters
- $entity : User
-
The user to save
Return values
int —The user ID
updateApiToken()
Update the API token.
public
updateApiToken(int $userId, string|null $token, DateTimeImmutable|null $expires) : bool
Parameters
- $userId : int
-
User ID
- $token : string|null
-
API token (null to clear)
- $expires : DateTimeImmutable|null
-
Token expiration
Return values
bool —True if updated
updateLastLogin()
Update the last login timestamp.
public
updateLastLogin(int $userId) : bool
Parameters
- $userId : int
-
User ID
Return values
bool —True if updated
updatePassword()
Update the password hash.
public
updatePassword(int $userId, string $passwordHash) : bool
Parameters
- $userId : int
-
User ID
- $passwordHash : string
-
New password hash
Return values
bool —True if updated
updatePasswordResetToken()
Update the password reset token.
public
updatePasswordResetToken(int $userId, string|null $token, DateTimeImmutable|null $expires) : bool
Parameters
- $userId : int
-
User ID
- $token : string|null
-
Password reset token (null to clear)
- $expires : DateTimeImmutable|null
-
Token expiration
Return values
bool —True if updated
updateRememberToken()
Update the remember-me token.
public
updateRememberToken(int $userId, string|null $token, DateTimeImmutable|null $expires) : bool
Parameters
- $userId : int
-
User ID
- $token : string|null
-
Remember token (null to clear)
- $expires : DateTimeImmutable|null
-
Token expiration
Return values
bool —True if updated
usernameExists()
Check if a username exists.
public
usernameExists(string $username[, int|null $excludeId = null ]) : bool
Parameters
- $username : string
-
Username to check
- $excludeId : int|null = null
-
User ID to exclude (for updates)