delete backend, starting over
This commit is contained in:
parent
babf9eb855
commit
f6a33cf620
51 changed files with 0 additions and 6655 deletions
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\User;
|
||||
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
|
||||
class CreateUserDto
|
||||
{
|
||||
public function __construct(
|
||||
public EmailAddress $email,
|
||||
public string $passwordHash,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\User;
|
||||
|
||||
use App\Database\UserModel;
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
|
||||
class PostgresUserRepository implements UserRepository
|
||||
{
|
||||
public function create(CreateUserDto $dto): User
|
||||
{
|
||||
$record = UserModel::create([
|
||||
'email' => $dto->email->value(),
|
||||
'password_hash' => $dto->passwordHash,
|
||||
]);
|
||||
|
||||
return new User(
|
||||
id: $record->id,
|
||||
email: new EmailAddress($record->email),
|
||||
passwordHash: $record->password_hash,
|
||||
);
|
||||
}
|
||||
|
||||
public function findByEmail(EmailAddress $email): ?User
|
||||
{
|
||||
$record = UserModel::where('email', $email->value())->first();
|
||||
|
||||
if ($record === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new User(
|
||||
id: $record->id,
|
||||
email: new EmailAddress($record->email),
|
||||
passwordHash: $record->password_hash,
|
||||
);
|
||||
}
|
||||
|
||||
public function find(int $id): ?User
|
||||
{
|
||||
$record = UserModel::find($id);
|
||||
|
||||
if ($record === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new User(
|
||||
id: $record->id,
|
||||
email: new EmailAddress($record->email),
|
||||
passwordHash: $record->password_hash,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\User;
|
||||
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
|
||||
class User
|
||||
{
|
||||
public function __construct(
|
||||
private int $id,
|
||||
private EmailAddress $email,
|
||||
private string $passwordHash,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getEmail(): EmailAddress
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getPasswordHash(): string
|
||||
{
|
||||
return $this->passwordHash;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\User;
|
||||
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
|
||||
interface UserRepository
|
||||
{
|
||||
public function create(CreateUserDto $dto): User;
|
||||
|
||||
public function findByEmail(EmailAddress $email): ?User;
|
||||
|
||||
public function find(int $id): ?User;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue