Forcing every call site to be explicit about admin status and password eliminates a class of bugs where an unintended isAdmin=false or empty passwordHash could silently slip through. The CreateUserTest case that asserted the isAdmin default is dropped since the default no longer exists.
35 lines
586 B
PHP
35 lines
586 B
PHP
<?php
|
|
|
|
namespace App\User;
|
|
|
|
use App\ValueObjects\EmailAddress;
|
|
|
|
class User
|
|
{
|
|
public function __construct(
|
|
private int $id,
|
|
private EmailAddress $email,
|
|
private string $passwordHash,
|
|
private bool $isAdmin,
|
|
) {}
|
|
|
|
public function getId(): int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getEmail(): EmailAddress
|
|
{
|
|
return $this->email;
|
|
}
|
|
|
|
public function getPasswordHash(): string
|
|
{
|
|
return $this->passwordHash;
|
|
}
|
|
|
|
public function isAdmin(): bool
|
|
{
|
|
return $this->isAdmin;
|
|
}
|
|
}
|