diff --git a/src/Hash/HMAC_SHA1.php b/src/Hash/HMAC_SHA1.php index c52117f..900251a 100644 --- a/src/Hash/HMAC_SHA1.php +++ b/src/Hash/HMAC_SHA1.php @@ -20,7 +20,7 @@ class HMAC_SHA1 implements HashInterface return $this->hash($key, \dechex($val)); } - public function hashType(): string + public static function hashType(): string { return "SHA1"; } @@ -28,7 +28,7 @@ class HMAC_SHA1 implements HashInterface /** @SuppressWarnings(PHPMD.StaticAccess) */ public static function keygen(): string { - return Base32::encodeUpper(random_bytes(this.DEFAULT_SECRET_SIZE)); + return Base32::encodeUpper(random_bytes(this::DEFAULT_SECRET_SIZE)); } } diff --git a/src/HashInterface.php b/src/HashInterface.php index f2cf14f..f765852 100644 --- a/src/HashInterface.php +++ b/src/HashInterface.php @@ -6,7 +6,7 @@ interface HashInterface { public function hash(string $key, string $val): string; public function hashNumeric(string $key, int $val): string; - public function hashType(): string; + public static function hashType(): string; public static function keygen(): string; } diff --git a/src/Required/PersistenceInterface.php b/src/Required/PersistenceInterface.php index d62b4a3..423b6fc 100644 --- a/src/Required/PersistenceInterface.php +++ b/src/Required/PersistenceInterface.php @@ -47,7 +47,7 @@ interface PersistenceInterface * @param mixed $index Whatever data needed to index into your database and identify a particular user * @return null|string */ - public function getSecret(mixed $index): null|string; + public function getSecret(mixed $index): ?string; /** * Gets and returns the last successful challenge timestamp to enforce the One-Time aspect of a TOTP. diff --git a/src/Session/Base.php b/src/Session/Base.php index 80cc6b9..08078de 100644 --- a/src/Session/Base.php +++ b/src/Session/Base.php @@ -40,7 +40,12 @@ class Base implements SessionInterface public function get(string $key): mixed { - return $_SESSION[$this->prefix($key)]; + $key = $this->prefix($key); + if (isset($_SESSION[$key])) + { + return $_SESSION[$key]; + } + return null; } }