Refactor some of the query strings, update the documentation.
This commit is contained in:
parent
e8a9624ba1
commit
4d25d3039a
@ -11,15 +11,18 @@ use Slovocast\Infrastructure\Api\Database\DatabaseHandlerInterface;
|
||||
|
||||
class UserRepository implements UserRepositoryInterface
|
||||
{
|
||||
const CREATE_QUERY = "INSERT INTO users (email, password, name)
|
||||
const QUERY_CREATE = "INSERT INTO users (email, password, name)
|
||||
VALUES (:email, :password, :name)";
|
||||
|
||||
const UPDATE_QUERY = "UPDATE users
|
||||
const QUERY_UPDATE = "UPDATE users
|
||||
SET email = :email,
|
||||
name = :name,
|
||||
password = :password
|
||||
WHERE id = :id";
|
||||
|
||||
const QUERY_SELECT_BY_ID = "";
|
||||
const QUERY_SELECT_BY_EMAIL = "";
|
||||
|
||||
public function __construct(
|
||||
private DatabaseHandlerInterface $db,
|
||||
private UserAuthorizationInterface $userAuth
|
||||
@ -76,7 +79,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
$results = $this->db->execute(self::CREATE_QUERY, [
|
||||
$results = $this->db->execute(self::QUERY_CREATE, [
|
||||
':email' => $user->getEmail(),
|
||||
':password' => $this->userAuth->hash($user->getPassword()),
|
||||
':name' => $user->getName(),
|
||||
@ -94,13 +97,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
|
||||
public function update(User $user): bool
|
||||
{
|
||||
$query = "UPDATE users
|
||||
SET email = :email,
|
||||
name = :name,
|
||||
password = :password
|
||||
WHERE id = :id";
|
||||
|
||||
$results = $this->db->execute(self::UPDATE_QUERY, [
|
||||
$results = $this->db->execute(self::QUERY_UPDATE, [
|
||||
':email' => $user->getEmail(),
|
||||
':name' => $user->getName(),
|
||||
':password' => $this->userAuth->hash($user->getPassword()),
|
||||
|
@ -8,6 +8,12 @@ interface UserRepositoryInterface
|
||||
{
|
||||
public function get(int $id): User;
|
||||
public function getFromEmail(string $email): User;
|
||||
|
||||
/**
|
||||
* @TODO Add methods for getting a User based on other related data, such
|
||||
* as the Channel or Episode.
|
||||
*/
|
||||
|
||||
public function create(User $user): bool;
|
||||
public function update(User $user): bool;
|
||||
public function delete(User $user): bool;
|
||||
|
Loading…
Reference in New Issue
Block a user