Clean code and use const

Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>
This commit is contained in:
Jean-Yves 2024-09-24 20:12:16 +02:00
parent d674ba4f6e
commit 56aa613dfb
No known key found for this signature in database
GPG key ID: 644C8B9C4CABAEF7
2 changed files with 20 additions and 16 deletions

View file

@ -4,14 +4,14 @@ namespace AIO\Auth;
use AIO\Data\ConfigurationManager; use AIO\Data\ConfigurationManager;
use AIO\Data\DataConst; use AIO\Data\DataConst;
use \DateTime; use DateTime;
class AuthManager { class AuthManager {
private const string SESSION_KEY = 'aio_authenticated'; private const string SESSION_KEY = 'aio_authenticated';
private ConfigurationManager $configurationManager;
public function __construct(ConfigurationManager $configurationManager) { public function __construct(
$this->configurationManager = $configurationManager; private readonly ConfigurationManager $configurationManager
) {
} }
public function CheckCredentials(string $password): bool { public function CheckCredentials(string $password): bool {

View file

@ -2,11 +2,11 @@
namespace AIO\Auth; namespace AIO\Auth;
use AIO\Data\ConfigurationManager; use Random\RandomException;
class PasswordGenerator class PasswordGenerator {
{
private array $words = [ private const array WORDS = [
'abacus', 'abacus',
'abdomen', 'abdomen',
'abdominal', 'abdominal',
@ -7785,6 +7785,10 @@ class PasswordGenerator
'zoom', 'zoom',
]; ];
/**
* @throws RandomException
*/
public function GeneratePassword(int $length): string { public function GeneratePassword(int $length): string {
$password = ''; $password = '';
@ -7792,7 +7796,7 @@ class PasswordGenerator
if ($password !== '') { if ($password !== '') {
$password = $password . ' '; $password = $password . ' ';
} }
$password = $password . $this->words[random_int(0, 7775)]; $password = $password . PasswordGenerator::WORDS[random_int(0, 7775)];
} }
return $password; return $password;