diff --git a/src/HOTP.php b/src/HOTP.php index e6bea73..67bd322 100644 --- a/src/HOTP.php +++ b/src/HOTP.php @@ -77,9 +77,11 @@ public function verify(string $otp, null|int $counter = null, null|int $window = return $this->verifyOtpWithWindow($otp, $counter, $window); } - public function setCounter(int $counter): void + public function setCounter(int $counter): static { $this->setParameter('counter', $counter); + + return $this; } /** diff --git a/src/HOTPInterface.php b/src/HOTPInterface.php index 915569a..e606d44 100644 --- a/src/HOTPInterface.php +++ b/src/HOTPInterface.php @@ -32,5 +32,5 @@ public static function create( int $digits = 6 ): self; - public function setCounter(int $counter): void; + public function setCounter(int $counter): static; } diff --git a/src/OTPInterface.php b/src/OTPInterface.php index 5ce1467..7b0a731 100644 --- a/src/OTPInterface.php +++ b/src/OTPInterface.php @@ -25,14 +25,14 @@ public static function generate(): self; /** * @param non-empty-string $secret */ - public function setSecret(string $secret): void; + public function setSecret(string $secret): static; - public function setDigits(int $digits): void; + public function setDigits(int $digits): static; /** * @param non-empty-string $digest */ - public function setDigest(string $digest): void; + public function setDigest(string $digest): static; /** * @return non-empty-string Return the OTP at the specified timestamp @@ -57,7 +57,7 @@ public function getSecret(): string; /** * @param non-empty-string $label The label of the OTP */ - public function setLabel(string $label): void; + public function setLabel(string $label): static; /** * @return non-empty-string|null The label of the OTP @@ -72,7 +72,7 @@ public function getIssuer(): ?string; /** * @param non-empty-string $issuer */ - public function setIssuer(string $issuer): void; + public function setIssuer(string $issuer): static; /** * @return bool If true, the issuer will be added as a parameter in the provisioning URI diff --git a/src/ParameterTrait.php b/src/ParameterTrait.php index dc92861..74d6ff6 100644 --- a/src/ParameterTrait.php +++ b/src/ParameterTrait.php @@ -57,9 +57,11 @@ public function getLabel(): null|string return $this->label; } - public function setLabel(string $label): void + public function setLabel(string $label): static { $this->setParameter('label', $label); + + return $this; } public function getIssuer(): null|string @@ -67,9 +69,11 @@ public function getIssuer(): null|string return $this->issuer; } - public function setIssuer(string $issuer): void + public function setIssuer(string $issuer): static { $this->setParameter('issuer', $issuer); + + return $this; } public function isIssuerIncludedAsParameter(): bool @@ -128,19 +132,25 @@ public function setParameter(string $parameter, mixed $value): void } } - public function setSecret(string $secret): void + public function setSecret(string $secret): static { $this->setParameter('secret', $secret); + + return $this; } - public function setDigits(int $digits): void + public function setDigits(int $digits): static { $this->setParameter('digits', $digits); + + return $this; } - public function setDigest(string $digest): void + public function setDigest(string $digest): static { $this->setParameter('algorithm', $digest); + + return $this; } /** diff --git a/src/TOTP.php b/src/TOTP.php index 6bc87ee..d08c9c7 100644 --- a/src/TOTP.php +++ b/src/TOTP.php @@ -138,14 +138,18 @@ public function getProvisioningUri(): string return $this->generateURI('totp', $params); } - public function setPeriod(int $period): void + public function setPeriod(int $period): static { $this->setParameter('period', $period); + + return $this; } - public function setEpoch(int $epoch): void + public function setEpoch(int $epoch): static { $this->setParameter('epoch', $epoch); + + return $this; } /** diff --git a/src/TOTPInterface.php b/src/TOTPInterface.php index a79fedc..2efda86 100644 --- a/src/TOTPInterface.php +++ b/src/TOTPInterface.php @@ -29,9 +29,9 @@ public static function create( int $digits = self::DEFAULT_DIGITS ): self; - public function setPeriod(int $period): void; + public function setPeriod(int $period): static; - public function setEpoch(int $epoch): void; + public function setEpoch(int $epoch): static; /** * Return the TOTP at the current time.