From 015f0c70b153ca5129be2845a728236e769ef570 Mon Sep 17 00:00:00 2001 From: Dave M Date: Wed, 12 Oct 2022 18:18:36 +0000 Subject: [PATCH] - hashPassword can now be used as a standalone method --- src/Entity/User.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Entity/User.php b/src/Entity/User.php index 9de20d0..a0e499e 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -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