- hashPassword can now be used as a standalone method

This commit is contained in:
Dave M. 2022-10-12 18:18:36 +00:00
parent fed3bc7f85
commit 015f0c70b1
1 changed files with 4 additions and 4 deletions

View File

@ -85,7 +85,7 @@ class User {
public function __toString() : string
{
return $this->fullname();
return "{$this->firstName} {$this->lastName}";
}
public function setPassword($password) : self
@ -95,16 +95,16 @@ class User {
return $this->hashPassword();
}
public function hashPassword() : self
public function hashPassword(? string $password = null) : self
{
$this->password = password_hash($this->password, PASSWORD_DEFAULT);
$this->password = password_hash($password ?: $this->password, PASSWORD_DEFAULT);
return $this;
}
public function verifyPassword(string $password) : bool
{
return password_verify($password, $this->password );
return password_verify($password, $this->password);
}
public function fullname() : string