Skip to content

Commit 72e9dd3

Browse files
committed
Add missing return type and use early return
1 parent 3edc522 commit 72e9dd3

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/Models/Concerns/HasPassword.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,24 +198,22 @@ public function getPasswordSalt(string $method): ?string
198198

199199
/**
200200
* Determine the password hash method to use from the users current password.
201-
*
202-
* @return string|void
203201
*/
204-
public function determinePasswordHashMethod()
202+
public function determinePasswordHashMethod(): ?string
205203
{
206204
if (! $password = $this->password) {
207-
return;
205+
return null;
208206
}
209207

210208
if (! $method = Password::getHashMethod($password)) {
211-
return;
209+
return null;
212210
}
213211

214-
[,$algo] = array_pad(
215-
Password::getHashMethodAndAlgo($password) ?? [],
216-
$length = 2,
217-
$value = null
218-
);
212+
if (! $hashAndAlgo = Password::getHashMethodAndAlgo($password)) {
213+
return $method;
214+
}
215+
216+
[,$algo] = array_pad(array: $hashAndAlgo, length: 2, value: null);
219217

220218
return match ((int) $algo) {
221219
Password::CRYPT_SALT_TYPE_MD5 => 'md5'.$method,

0 commit comments

Comments
 (0)