PDOUserRepository
in package
implements
UserRepositoryInterface
Read onlyYes
Tags
Table of Contents
Interfaces
- UserRepositoryInterface
- Describes user repository behavior
Properties
- $DATE_FORMAT : string
- $dbHelper : DatabaseService
- $TABLE_NAME : string
Methods
- __construct() : mixed
- add() : int
- Persists a new user entity.
- delete() : bool
- Deletes a user by its ID.
- findAll() : array<string|int, User>
- Retrieves all users from storage.
- findByExactUsername() : User|null
- Finds a user by exact username match.
- findById() : User
- Finds a user by its ID.
- findByUsernamePartial() : array<string|int, User>
- Finds a user by partial username match.
- update() : bool
- Updates an existing user entity.
- updatePassword() : bool
- Updates user password hash.
- mapRow() : User
- Maps database row to User entity.
Properties
$DATE_FORMAT
private
string
$DATE_FORMAT
$dbHelper
private
DatabaseService
$dbHelper
$TABLE_NAME
private
string
$TABLE_NAME
Methods
__construct()
public
__construct(DatabaseService $dbHelper, string $TABLE_NAME, string $DATE_FORMAT) : mixed
Parameters
- $dbHelper : DatabaseService
- $TABLE_NAME : string
- $DATE_FORMAT : string
add()
Persists a new user entity.
public
add(User $user) : int
Parameters
- $user : User
-
The user entity to add
Tags
Return values
int —user id
delete()
Deletes a user by its ID.
public
delete(int $id) : bool
Parameters
- $id : int
-
The user ID to delete
Tags
Return values
bool —True if deletion was successful, false otherwise
findAll()
Retrieves all users from storage.
public
findAll() : array<string|int, User>
Tags
Return values
array<string|int, User> —Array of all user entities
findByExactUsername()
Finds a user by exact username match.
public
findByExactUsername(string $username) : User|null
Parameters
- $username : string
-
The username to search for
Tags
Return values
User|null —The user entity or null if not found
findById()
Finds a user by its ID.
public
findById(int $id) : User
Parameters
- $id : int
-
The user ID
Tags
Return values
User —The user entity
findByUsernamePartial()
Finds a user by partial username match.
public
findByUsernamePartial(string $username) : array<string|int, User>
Parameters
- $username : string
-
The partial username to search for
Tags
Return values
array<string|int, User> —Array of matching user entities
update()
Updates an existing user entity.
public
update(User $user) : bool
Parameters
- $user : User
-
The user entity with updated data
Tags
Return values
bool —True if update was successful, false otherwise
updatePassword()
Updates user password hash.
public
updatePassword(int $id, string $newPasswordHash) : bool
Parameters
- $id : int
-
The user ID
- $newPasswordHash : string
-
The new password hash
Tags
Return values
bool —True if update was successful, false otherwise
mapRow()
Maps database row to User entity.
private
mapRow(array<string|int, mixed> $row) : User
Parameters
- $row : array<string|int, mixed>