Documentation

UserRepository
in package

Class UserRepository

This class manages the persistence of users in the database.

Table of Contents

Properties

$connection  : PDO
$table  : string
$tableAssoc  : string

Methods

__construct()  : mixed
Constructor for the UserRepository class.
createUser()  : bool
Creates a new user in the database.
deleteUser()  : bool
Deletes a user from the database by their ID.
getAllUsers()  : array<string|int, mixed>
Retrieves all users from the database.
getUserById()  : User|null
Retrieves a user from the database by their ID.
updateUser()  : bool
Updates an existing user in the database.

Properties

Methods

__construct()

Constructor for the UserRepository class.

public __construct() : mixed

Initializes the database connection.

createUser()

Creates a new user in the database.

public createUser(User $user) : bool
Parameters
$user : User

The user to be created.

Return values
bool

Returns true if the user was successfully created, false otherwise.

deleteUser()

Deletes a user from the database by their ID.

public deleteUser(int $idUser) : bool
Parameters
$idUser : int

The ID of the user to be deleted.

Return values
bool

Returns true if the user was successfully deleted, false otherwise.

getAllUsers()

Retrieves all users from the database.

public getAllUsers() : array<string|int, mixed>
Return values
array<string|int, mixed>

Returns an array of all users found.

getUserById()

Retrieves a user from the database by their ID.

public getUserById(int $idUser) : User|null
Parameters
$idUser : int

The ID of the user to be retrieved.

Tags
throws
InvalidArgumentException

If the user's role name is unknown.

Return values
User|null

Returns the user found or null if not found.

updateUser()

Updates an existing user in the database.

public updateUser(User $user) : bool
Parameters
$user : User

The user to be updated.

Return values
bool

Returns true if the user was successfully updated, false otherwise.


        
On this page

Search results